I have an unsafe WebSocket application. But my site uses https, and I need a Secure WebSocket connection so that Firefox does not complain that the connection is unsafe.
I use php-websocket-server for my WebSocket server with PhP 5.2.9, so when I use WebSocket security, I cannot decrypt packets using the openssl_decrypt function.
This is why I used stunnel to decrypt packets sent by the client using wss to do this, I mapped the client WebSocket to 12345, the WebSocket server port for 54321, then I added stunnel in server mode:
[wsServer] accept = 12345 connect = 192.168.1.227:54321
In this configuration, my application works fine on Chrome via https + wss. But in Firefox there is a problem during a handshake, it seems that the header does not have Sec-WebSocket-Version
and Sec-WebSocket-Key
. I do not understand, because it works on Firefox through http + ws.
Thanks in advance for your help.
Edit: I added a certificate exception on port 12345, now the handshake is going well, because I think Firefox now has a Sec-WebSocket-Key
.
Here's a working header request with Firefox (more than a Chrome request):
GET / HTTP/1.1 Host: 192.168.1.227:12345 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/;q=0.8 Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate DNT: 1 Connection: keep-alive, Upgrade Sec-WebSocket-Version: 13 Origin: https://192.168.1.227 Sec-WebSocket-Protocol: HyBi-00 Sec-WebSocket-Key: 65nHN33M6drIPjQHcGK8pA== Pragma: no-cache Cache-Control: no-cache Upgrade: websocket