Search code examples
javascriptandroidsecurityhttpstablet

Allowing webcam access without https on android tablet


Is it possible to allow webcam access without HTTPS on a website through an Android tablet on a browser?

Possibly through Javascript or PHP?


Solution

  • In a single word the answer is NO. It is possible to get webcam access only on localhost and https connections for security.

    W3 API specification states

    When on an insecure origin [mixed-content], User Agents are encouraged to warn about usage of navigator.mediaDevices.getUserMedia, navigator.getUserMedia, and any prefixed variants in their developer tools, error logs, etc. It is explicitly permitted for User Agents to remove these APIs entirely when on an insecure origin, as long as they remove all of them at once (e.g., they should not leave just the prefixed version available on insecure origins).

    Chrome, starting from version 47 implements this security policy (Source):

    Starting with Chrome 47, getUserMedia() requests are only allowed from secure origins: HTTPS or localhost.

    So you can't access Camera without a secure connection.