允许在安卓平板上使用摄像头而不需要 HTTPS。

huangapple go评论94阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年1月3日 17:27:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/59576004.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定