aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2016-10-11 09:20:45 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2016-10-11 09:20:45 +0200
commiteeab466c7321360ee67196525f205609510d72b6 (patch)
treee896846770f0a1e5873511289486f5254a2298e4
parentc0aaafcab152e292617764fdfb4f0248c8430ccf (diff)
parent97691c9f7d7af19260e02553ce501142224a706e (diff)
downloadWebsocket-eeab466c7321360ee67196525f205609510d72b6.zip
Websocket-eeab466c7321360ee67196525f205609510d72b6.tar.gz
Websocket-eeab466c7321360ee67196525f205609510d72b6.tar.bz2
Connection: Start TLS encryption on handshake.
If the URI is `wss://`, then the connection must be encrypted. This step must be done early before the handshake starts.
-rw-r--r--Server.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/Server.php b/Server.php
index d7c3fdb..972087e 100644
--- a/Server.php
+++ b/Server.php
@@ -89,6 +89,12 @@ class Server extends Connection
protected function doHandshake()
{
$connection = $this->getConnection();
+
+ if (true === $connection->getSocket()->isSecured() &&
+ false === $connection->isEncrypted()) {
+ $connection->enableEncryption(true, $connection::ENCRYPTION_TLS);
+ }
+
$buffer = $connection->read(2048);
$request = $this->getRequest();
$request->parse($buffer);