@@ -401,6 +401,48 @@ $server = new Server('[::1]:8080', $loop, array(
401401 For BC reasons, you can also pass the TCP socket context options as a simple
402402 array without wrapping this in another array under the ` tcp ` key.
403403
404+ You can start a secure TLS (formerly known as SSL) server by simply prepending
405+ the ` tls:// ` URI scheme.
406+ Internally, it will wait for plaintext TCP/IP connections and then performs a
407+ TLS handshake for each connection.
408+ It thus requires valid [ TLS context options] ( http://php.net/manual/en/context.ssl.php ) ,
409+ which in its most basic form may look something like this if you're using a
410+ PEM encoded certificate file:
411+
412+ ``` php
413+ $server = new Server('tls://127.0.0.1:8080', $loop, array(
414+ 'tls' => array(
415+ 'local_cert' => 'server.pem'
416+ )
417+ ));
418+ ```
419+
420+ > Note that the certificate file will not be loaded on instantiation but when an
421+ incoming connection initializes its TLS context.
422+ This implies that any invalid certificate file paths or contents will only cause
423+ an ` error ` event at a later time.
424+
425+ If your private key is encrypted with a passphrase, you have to specify it
426+ like this:
427+
428+ ``` php
429+ $server = new Server('tls://127.0.0.1:8000', $loop, array(
430+ 'tls' => array(
431+ 'local_cert' => 'server.pem',
432+ 'passphrase' => 'secret'
433+ )
434+ ));
435+ ```
436+
437+ > Note that available [ TLS context options] ( http://php.net/manual/en/context.ssl.php ) ,
438+ their defaults and effects of changing these may vary depending on your system
439+ and/or PHP version.
440+ The outer context array allows you to also use ` tcp ` (and possibly more)
441+ context options at the same time.
442+ Passing unknown context options has no effect.
443+ If you do not use the ` tls:// ` scheme, then passing ` tls ` context options
444+ has no effect.
445+
404446Whenever a client connects, it will emit a ` connection ` event with a connection
405447instance implementing [ ` ConnectionInterface ` ] ( #connectioninterface ) :
406448
0 commit comments