Websocket 和自签名 SSL 证书有什么问题

我有一个项目在 Intranet 上运行,所以我没有购买任何 SSL 证书或域名.相反,我创建了自签名证书.我有两层,其中一层是网络服务/websocket,另一层是视图.所有 https 连接一切正常,因此所有页面,但浏览器无法与 ws 或 wss 链接建立连接(已尝试端口 8443,443,8080).如果我使用 localhost 而不是我的 ip 编写链接,它可以完美运行,但是我无法从其他设备使用它.我将证书创建为 RSA/2048.我的项目在 Ubuntu 18.04 上运行.服务器端是用 Java-Spring Boot 编写的.

I have a project runs on intranet, so I didn't buy any SSL certificate or domain name. Instead, I created self-signed certificate. I have two layer one of which is web service/websocket and the other is view. Everything is OK for all https connections, hence all pages, but browser could not make connection with ws or wss links(was tried ports 8443,443,8080). If I write link with localhost instead of my ip, it works perfectly, but then I cannot use it from another device. I created certificete as RSA/2048. My project runs on Ubuntu 18.04. Serverside was written in Java-Spring Boot.

推荐答案

如果其他人需要答案,我从 这里.总而言之,问题出在Firefox,而不是其他浏览器.主要原因是火狐不接受wss链接的证书,其实第一个以https开头的链接也是同一个证书.解决方案是通过将 wss 转换为 https 并接受该链接的权限来转到以 wss 开头的链接,并且一切正常:)

If someone else need an answer, I got it from here. As summary, the problem is about Firefox, not about other browsers. Main reason is that Firefox do not accept certificate of wss link, in fact it is also the same certificate for the first connection link start with https. Solution is to go to the link started with wss by chancing wss to https and accept privilege of that link, and everthing works fine :)

相关文章