title: Websocket PHP server using SSL (WSS)
body: <p>I'm asking because I'm in dead end with my <code>PHP</code> websocket server. I'm looking for a solution for 2 weeks and I visited all results in <code>Google</code> with tags: <code>websocket</code>, <code>SSL</code>, <code>WSS</code>.  </p>
  
  <p>The problem is caused by using <code>WSS</code> <code>(websocket secure)</code>, my server works perfect with <code>WS</code>. But I have to use <code>SSL</code>, 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 <code>openssl_*</code> functions, so I wrote a code:  </p>
  
  <pre><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);
  </code></pre>
  
  <p>And I get errors:  </p>
  
  <pre><code>error:0407006A:rsa routines:RSA_padding_check_PKCS1_type_1:block type is not 01  
  </code></pre>
  
  <p>or  </p>
  
  <pre><code>error:04065072:rsa routines:RSA_EAY_PRIVATE_DECRYPT:padding check failed  
  </code></pre>
  
  <p>Of cause <code>$open</code> is null. I tried with each padding option and errors were the same.</p>
  
  <p>Any ideas?  </p>