简体   繁体   中英

Websocket PHP server using SSL (WSS)

I'm asking because I'm in dead end with my PHP websocket server. I'm looking for a solution for 2 weeks and I visited all results in Google with tags: websocket , SSL , WSS .

The problem is caused by using WSS (websocket secure) , my server works perfect with WS . But I have to use SSL , I can't give up this. More precisely, when client (browser) sends handshake to server, it is encrypted. I think so, because it is a mix of really strange chars. Next, I thought I should decrypt this string with openssl_* functions, so I wrote a code:

//$pKey - decrypted private key of my SSL certificate
//$buffer - string with strange chars - probably encrypted handshake
$privateKey = openssl_pkey_get_private($pKey);
openssl_private_decrypt($buffer , $open , $privateKey);
openssl_free_key($privateKey);

And I get errors:

error:0407006A:rsa routines:RSA_padding_check_PKCS1_type_1:block type is not 01  

or

error:04065072:rsa routines:RSA_EAY_PRIVATE_DECRYPT:padding check failed  

Of cause $open is null. I tried with each padding option and errors were the same.

Any ideas?

I recommend having a separate process (Nginx/STunnel) handle SSL.

See NGINX to reverse proxy websockets AND enable SSL (wss://)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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