我正在使用对撞机(https://github.com/webrtc/apprtc/tree/master/src/collider - 一个 websockets 服务器),我正在尝试添加 SSL/TLS 支持。我为此生成了自签名证书:
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:CA
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:testwebsite.com
Organizational Unit Name (eg, section) []:Engineering
Common Name (e.g. server FQDN or YOUR name) []:www.testwebsite.com
Email Address []:testwebsite@gmail.com
当我运行对撞机时,我看到这个错误:
2017/06/05 21:25:50 Error Run: crypto/tls: failed to parse private key
当我使用生成时(基于 http://www.kaihag.com/https-and-go/ ):
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.pem -out cert.pem
我收到这个错误:
2017/06/05 22:11:31 http: TLS handshake error from <some-ip>:1082: remote error: unknown certificate
如何解决这个问题?
注意:对撞机使用golang.org/x/net/websocket
最佳答案
我最终从以下位置获得了证书:https://certbot.eff.org/#ubuntuxenial-other
certbot certonly --standalone -d example.com -d www.example.com
我必须使用 fullchain.pem 而不是 cert.pem 才能让这个对撞机工作:
关于使用 Websockets 服务器的 SSL/TLS - go lang,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44401356/