diff --git a/src/Ratchet/App.php b/src/Ratchet/App.php index f1cd4ddb..09ed6c49 100644 --- a/src/Ratchet/App.php +++ b/src/Ratchet/App.php @@ -1,5 +1,8 @@ httpHost = $httpHost; $this->port = $port; - $socket = new Reactor($address . ':' . $port, $loop); + $options = []; + + if (null !== $tlsOptions) { + $options[self::OPTION_TLS] = $tlsOptions->toArray(); + } + + $socket = new Reactor($address . ':' . $port, $loop, $options); $this->routes = new RouteCollection; $this->_server = new IoServer(new HttpServer(new Router(new UrlMatcher($this->routes, new RequestContext))), $socket, $loop); diff --git a/src/Ratchet/Tls/TlsOptions.php b/src/Ratchet/Tls/TlsOptions.php new file mode 100644 index 00000000..e36d35cb --- /dev/null +++ b/src/Ratchet/Tls/TlsOptions.php @@ -0,0 +1,64 @@ +certificatePath = $certificatePath; + $this->certificateKey = $certificateKey; + $this->allowSelfSigned = $allowSelfSigned; + $this->verifyPeer = $verifyPeer; + $this->verifyPeerName = $verifyPeerName; + } + + /** + * @return array + */ + public function toArray() + { + return [ + self::FIELD_CERTIFICATE_PATH => $this->certificatePath, + self::FIELD_CERTIFICATE_KEY => $this->certificateKey, + self::FIELD_ALLOW_SELF_SIGNED => $this->allowSelfSigned, + self::FIELD_VERIFY_PEER => $this->verifyPeer, + self::FIELD_VERIFY_PEER_NAME => $this->verifyPeerName, + ]; + } +} \ No newline at end of file