返回信息流最近在做一个基于web的视频通信项目,发现使用非localhost(即直接输入网址的方式)访问时,在http连接下调用navigator.webkitGetUserMedia()总是显示PermissionDeniedError,提示信息如下:
现在问题是这样的,如果我采用https连接的话,因为中间要采用websocket通信,就必须使用wss(websocket secure),我的服务器端使用的是Tomcat,只能支持ws(websocket),无法支持wss,就导致项目无法继续,测试都无法做。
现在想问下有没有什么办法,让Chrome在HTTP连接下可以通过webkitGetUserMedia()调用摄像头,或者另一种方式,在HTTPS连接下,可以使用ws进行对外请求,都可以解决这个问题,我在HTTPS模式下使用ws进行连接问题提示如下:
求助各位大神哇~[ema1]
这是一条镜像帖。来源:北邮人论坛 / java-script / #3127同步于 2017/11/3
该镜像源已超过 30 天没有更新,可能在源站已被删除。
JavaScript机器人发帖
Chrome在HTTP下如何调用getUserMeida(),总是显示PermissionDen
dadishu
2017/11/3镜像同步3 回复
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
Testing a Powerful Feature
If a feature is powerful and not available on HTTP, and you are a developer that needs to keep testing a feature on a server that does not have a valid certificate, you have several options:
1. localhost is treated as a secure origin over HTTP, so if you're able to run your server from localhost, you should be able to test the feature on that server.
2. You can run chrome with the --unsafely-treat-insecure-origin-as-secure="http://example.com" flag (replacing "example.com" with the origin you actually want to test), which will treat that origin as secure for this session. Note that you also need to include the --user-data-dir=/test/only/profile/dir to create a fresh testing profile for the flag to work. Note that on Android and ChromeOS this requires having a device with root access/dev mode.
3. Create a self-signed certificate for temporary testing. This requires advancing through an invalid certificate interstitial, which is generally not recommended, but testing without inputting sensitive information is a reasonable time to do so. Note that because of this interstitial click-through, we highly recommend options (1) and (2) instead, but they are difficult to do on mobile. See this post on setting up a self-signed certificate for a server for more information on how to do this.
We are hoping to come up with better metheds for testing powerful features on insecure origins, and we'll be sure to update this page once we've developed them. Feel free to contribute ideas to security-dev@chromium.org.
产品环境不可能允许你在不安全的行为的。https://stackoverflow.com/questions/43768161/using-ws-while-on-https-mixed-content