繁体   English   中英

Websocket ERR_SSL_PROTOCOL_ERROR 超过 https

[英]Websocket ERR_SSL_PROTOCOL_ERROR over https

我在服务器端使用 PHP 和 APACHE 网络服务器

如果我在 HTTPS 上使用安全 web 套接字协议:

在客户端,我使用 Javascript 连接 websocket。 以下是代码`

var wsUri = wss://mywebsite.com:8012/test/web-socket    
    websocket = new WebSocket(wsUri); 

    websocket.onopen = function(ev) { // connection is open 
        $('#message_box').append("<div class=\"system_msg\">Connected!</div>"); //notify user
}`

我在建立连接时收到错误 net::ERR_SSL_PROTOCOL_ERROR

同样适用于 http

我已通过将证书和密钥组合文件提供给 stream_context_set_option function 来解决此问题。 这解决了 ssl_protocol_error。

$context = stream_context_create();         
stream_context_set_option($context, 'ssl', 'local_cert', '/tmp/combined_cert.pem');         
stream_context_set_option($context, 'ssl', 'passphrase', '');           
stream_context_set_option($context, 'ssl', 'allow_self_signed', true);          
stream_context_set_option($context, 'ssl', 'verify_peer', false);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM