越来越WSS与安全通道及工作冲高

问题描述:

运行的Apache V2.4,PHP V5.6瓦特/ PHP-FPM,在CentOS 7越来越WSS与安全通道及工作冲高

所以我试图让WSS与安全通道&棘轮工作。我已经有了Ratchet的Hello World(http://socketo.me/docs/hello-world),可以在端口8080上使用非ssl上的测试代码成功运行。我可以从同一台机器telnet,也可以从另一台机器telnet。

通过阅读,我知道棘轮不支持ssl连接,但通过与stunnel包装通信,所以我设置了一个合适的证书监听端口8443 stunnel,似乎工作(如证明日志文件)。

当我尝试使用Firefox的暂存器中的wss进行连接时,出现以下错误:Firefox can't establish a connection to the server at wss://testserver.testdomain.com:8443我可以看到通过各种日志文件创建的连接,但是由于我无法通过线路通信创建一个可靠的wss连接。任何想法,我失踪或我搞砸了?登录/代码下面

暂存代码

var conn = new WebSocket('wss://testserver.testdomain.com:8443'); 
conn.onopen = function(e) { 
    console.log("Connection established!"); 
}; 

conn.onmessage = function(e) { 
    console.log(e.data); 
}; 

Stunnel的配置:

cert = /etc/httpd/ssl/ov_wildcard.pem 

[hublistener] 
accept = 8443 
connect = 8080 

Stunnel的日志:

2016.05.11 14:43:28 LOG5[38759:140614807435328]: stunnel 4.56 on x86_64-redhat-linux-gnu platform 
2016.05.11 14:43:28 LOG5[38759:140614807435328]: Compiled/running with OpenSSL 1.0.1e-fips 11 Feb 2013 
2016.05.11 14:43:28 LOG5[38759:140614807435328]: Threading:PTHREAD Sockets:POLL,IPv6 SSL:ENGINE,OCSP,FIPS Auth:LIBWRAP 
2016.05.11 14:43:28 LOG5[38759:140614807435328]: Reading configuration from file /etc/stunnel/stunnel.conf 
2016.05.11 14:43:28 LOG5[38759:140614807435328]: FIPS mode is enabled 
2016.05.11 14:43:28 LOG4[38759:140614807435328]: Insecure file permissions on /etc/httpd/ssl/cert.pem 
2016.05.11 14:43:28 LOG5[38759:140614807435328]: Configuration successful 
2016.05.11 14:45:59 LOG5[38765:140614807430912]: Service [hublistener] accepted connection from ***.***.***.***:39124 
2016.05.11 14:45:59 LOG5[38765:140614807430912]: connect_blocking: connected 127.0.0.1:8080 
2016.05.11 14:45:59 LOG5[38765:140614807430912]: Service [hublistener] connected remote server from 127.0.0.1:59795 

棘轮输出样本:

[[email protected] dev-hub]$ php module/HubListener/websocket.php 
New Connection! (307) 
New Connection! (317) 
Connection 317 sending message "second window line 1 
" to 1 other connection 
Connection 317 sending message "second window line 2 
" to 1 other connection 
New Connection! (318) 
Connection 318 sending message "GET/HTTP/1.1 
Host: testserver.testdomain.com:8443 
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0 FirePHP/0.7.4 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-US,en;q=0.5 
Accept-Encoding: gzip, deflate, br 
Sec-WebSocket-Version: 13 
Origin: https://testserver.testdomain.com 
Sec-WebSocket-Extensions: permessage-deflate 
Sec-WebSocket-Key: PrWlBjR2q6a0syT4oplnAQ== 
Cookie: PHPSESSID=ci7102qouvqprhdpk483hv6ar3; exclusive_offers_popup=1; __utma=213556497.27501638.1462814210.1462827970.1462831402.3; __utmc=213556497; __utmz=213556497.1462814210.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmv=213556497.|1=l=%2F=1 
x-insight: activate 
Connection: keep-alive, Upgrade 
Pragma: no-cache 
Cache-Control: no-cache 
Upgrade: websocket 

" to 2 other connections 

Telnet连接1

[[email protected] ~]$ telnet 127.0.0.1 8080 
Trying 127.0.0.1... 
Connected to 127.0.0.1. 
Escape character is '^]'. 
second window line 1 
second window line 2 
GET/HTTP/1.1 
Host: testserver.testdomain.com:8443 
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0 FirePHP/0.7.4 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-US,en;q=0.5 
Accept-Encoding: gzip, deflate, br 
Sec-WebSocket-Version: 13 
Origin: https://testserver.testdomain.com 
Sec-WebSocket-Extensions: permessage-deflate 
Sec-WebSocket-Key: PrWlBjR2q6a0syT4oplnAQ== 
Cookie: PHPSESSID=ci7102qouvqprhdpk483hv6ar3; exclusive_offers_popup=1; __utma=213556497.27501638.1462814210.1462827970.1462831402.3; __utmc=213556497; __utmz=213556497.1462814210.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmv=213556497.|1=l=%2F=1 
x-insight: activate 
Connection: keep-alive, Upgrade 
Pragma: no-cache 
Cache-Control: no-cache 
Upgrade: websocket 
+0

PHP文件里面,你使用nginx的或Apache? – mitchken

+0

apache v2.4,初步问题反映。 – Zxurian

+0

你能否确保一切正确设置也复制你的stunnel配置? – mitchken

我有我自己的机器上运行的棘轮的WebSocket和我也使用Apache2.4 为了使其工作在SSL我做了:

代理通插座

内(在/ etc/apache2的/)apache2.conf我加

这个经过我的WebSocket端口8080上运行到WSS://alpha.example.com/wss/

使确保您的安全通道的配置是正确的,这是我做的 (在/ etc /安全通道/)stunnel.conf内

cert = /etc/letsencrypt/live/www.example.com/cert.pem 
key = /etc/letsencrypt/live/www.example.com/privkey.pem 
[wss] 
accept = 8082 
connect = 8080 

提醒:改变路径我用你的路径键您键正在使用。

启动我的服务器我的用户端口8080作为棘轮例如

$webSock->listen(8080, '0.0.0.0'); // Binding to 0.0.0.0 means remotes can connect 
+1

我会在今晚尝试通过代理,看看是否会返回通信 – Zxurian