2

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?

Prophet
  • 32,350
  • 22
  • 54
  • 79
MateuszBlaszczyk
  • 133
  • 1
  • 3
  • 10

1 Answers1

0

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

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

Community
  • 1
  • 1
walkor
  • 276
  • 2
  • 4