“common name invalid” for a self-signed certificate for websocket server

天大地大妈咪最大 提交于 2020-02-06 16:14:12

问题


I'm trying to run this webrtc client/signaling server code, but after running the server with a new self-signed certificate I created by following the instructions of this tutorial, my chatclient.js couldn't connect to socket server:

connection = new WebSocket('wss://localhost:6503/', 'json');

this is the error displayed by chrome's console:

(chatclient.js:106) WebSocket connection to 'wss://localhost:6503/' failed: 
    Error in connection establishment: net::ERR_CERT_COMMON_NAME_INVALID

I then go to https://0.0.0.0:6503/ from chrome (the server is listening on port 6503), and this is the security tab from chrome inspector:

I'm guessing I need to set the correct common name during the generation of ssl certificate, to which I current set as 0.0.0.0:6503.

What should I set? Since this is a websocket's address and I have no idea which part to write?


回答1:


Set it to localhost which is the same host you're trying to connect to. You do not need to include the port. Note that you will need a certificate in production.

You might also want to check the highly useful Chrome flag which ignores certificate errors on localhost: chrome://flags/#allow-insecure-localhost



来源:https://stackoverflow.com/questions/54142899/common-name-invalid-for-a-self-signed-certificate-for-websocket-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!