英文:
Allowing webcam access without https on android tablet
问题
在Android平板上通过浏览器允许摄像头访问而不使用HTTPS是否可能?
可能通过Javascript或PHP实现?
英文:
Is it possible to allow webcam access without HTTPS on a website through an Android tablet on a browser?
Possibly through Javascript or PHP?
答案1
得分: 2
答案是“NO”。仅在本地主机和https连接上才能访问摄像头,以确保安全性。
W3 API 规范 表明
> 当在不安全的来源上 [混合内容] 时,建议用户代理在其开发者工具、错误日志等中警告使用 navigator.mediaDevices.getUserMedia、navigator.getUserMedia 和任何有前缀的变体。明确允许用户代理在不安全的来源上完全删除这些API,只要它们一次全部删除(例如,它们不应该在不安全的来源上仅保留有前缀的版本可用)。
Chrome,从版本47开始实施了这个安全策略(来源):
> 从Chrome 47开始,只允许从安全来源(HTTPS或localhost)进行getUserMedia()请求。
因此,您不能在没有安全连接的情况下访问摄像头。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论