title: PHP WebSocket Server using SSL
body: <p>I am trying to use websockets in my application which running in this environment :
  - Debian 8
  - Apache 2.4.10
  - PHP 5.6.30
  I use devristo/phpws package, and just trying to make their example works (time).
  Everything is ok on a HTTP context website and ws:// protocol connection, but when i try to put it on an HTTPS website and using wss:// protocol, it fail.</p>
  
  <p>I start the server via "php -q server.php", file content :</p>
  
  <pre><code>&lt;?php
  require_once("vendor/autoload.php");
  use Devristo\Phpws\Server\WebSocketServer;
  
  $loop = \React\EventLoop\Factory::create();
  
  // Create a logger which writes everything to the STDOUT
  $logger = new \Zend\Log\Logger();
  $writer = new Zend\Log\Writer\Stream("php://output");
  $logger-&gt;addWriter($writer);
  
  // Create a WebSocket server using SSL
  $server = new WebSocketServer("wss://X.X.X.X:9300", $loop, $logger);
  
  $loop-&gt;addPeriodicTimer(0.5, function() use($server, $logger){
      $time = new DateTime();
      $string = $time-&gt;format("Y-m-d H:i:s");
      $logger-&gt;notice("Broadcasting time to all clients: $string");
      foreach($server-&gt;getConnections() as $client)
          $client-&gt;sendString($string);
  });
  
  // Bind the server
  $server-&gt;bind();
  
  // Start the event loop
  $loop-&gt;run();
  </code></pre>
  
  <p>In other hand, i have a time.html, which contain :</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;WebSocket TEST&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Server Time&lt;/h1&gt;
  &lt;strong id="time"&gt;&lt;/strong&gt;
  
  &lt;script&gt;
      var socket = new WebSocket("wss://X.X.X.X:9300/");
      socket.onmessage = function(msg) {
          document.getElementById("time").innerText = msg.data;
      };
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The server start running without problems :</p>
  
  <pre><code>2017-11-24T11:47:57+01:00 NOTICE (5): phpws listening on ssl://X.X.X.X:9300
  2017-11-24T11:47:57+01:00 NOTICE (5): Broadcasting time to all clients: 2017-11-24 11:47:57
  2017-11-24T11:47:58+01:00 NOTICE (5): Broadcasting time to all clients: 2017-11-24 11:47:58
  ....
  </code></pre>
  
  <p>When i go on my page time.html in browser, the following JavaScript error comes in chrome :</p>
  
  <pre><code>VM725:164 WebSocket connection to 'wss://X.X.X.X:9300/' failed: Error in connection establishment: net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH
  </code></pre>
  
  <p>At the same time, server produces this error output :</p>
  
  <pre><code>PHP Warning:  stream_socket_accept(): SSL_R_NO_SHARED_CIPHER: no suitable shared cipher could be used.  This could be because the server is missing an SSL certificate (local_cert context option) in /var/www/web/sofive/k-zam/web/vendor/devristo/phpws/src/Devristo/Phpws/Server/WebSocketServer.php on line 141
  
  Warning: stream_socket_accept(): SSL_R_NO_SHARED_CIPHER: no suitable shared cipher could be used.  This could be because the server is missing an SSL certificate (local_cert context option) in /var/www/web/sofive/k-zam/web/vendor/devristo/phpws/src/Devristo/Phpws/Server/WebSocketServer.php on line 141
  PHP Warning:  stream_socket_accept(): Failed to enable crypto in /var/www/web/wstest/vendor/devristo/phpws/src/Devristo/Phpws/Server/WebSocketServer.php on line 141
  
  Warning: stream_socket_accept(): Failed to enable crypto in /var/www/web/wstest/vendor/devristo/phpws/src/Devristo/Phpws/Server/WebSocketServer.php on line 141
  PHP Warning:  stream_socket_accept(): accept failed: Success in /var/www/web/wstest/vendor/devristo/phpws/src/Devristo/Phpws/Server/WebSocketServer.php on line 141
  
  Warning: stream_socket_accept(): accept failed: Success in /var/www/web/wstest/vendor/devristo/phpws/src/Devristo/Phpws/Server/WebSocketServer.php on line 141
  </code></pre>
  
  <p>So i think i miss a certificate to pass to socket_context_create ? If yes, how to create this certificate, are there specs (ssl version ? etc), or do i need to pass the same as the one used for https website (generated with let's encrypt certbot) ?</p>