From 00b6b13023914c4e0bc33e8be49fd12f3b5ee3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Mon, 14 Dec 2015 13:14:39 +0100 Subject: [PATCH 1/2] PHP 5.6+ uses new SSL/TLS context options Backported from #61 --- src/SecureConnector.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/SecureConnector.php b/src/SecureConnector.php index f80c11b..35ddad8 100644 --- a/src/SecureConnector.php +++ b/src/SecureConnector.php @@ -18,14 +18,26 @@ public function __construct(ConnectorInterface $connector, LoopInterface $loop) public function create($host, $port) { - return $this->connector->create($host, $port)->then(function (Stream $stream) use ($host) { + $context = array( + 'SNI_enabled' => true, + 'peer_name' => $host + ); + + // legacy PHP < 5.6 ignores peer_name and requires legacy context options instead + if (PHP_VERSION_ID < 50600) { + $context += array( + 'SNI_server_name' => $host, + 'CN_match' => $host + ); + } + + return $this->connector->create($host, $port)->then(function (Stream $stream) use ($context) { // (unencrypted) TCP/IP connection succeeded // set required SSL/TLS context options - $resource = $stream->stream; - stream_context_set_option($resource, 'ssl', 'SNI_enabled', true); - stream_context_set_option($resource, 'ssl', 'SNI_server_name', $host); - stream_context_set_option($resource, 'ssl', 'peer_name', $host); + foreach ($context as $name => $value) { + stream_context_set_option($stream->stream, 'ssl', $name, $value); + } // try to enable encryption return $this->streamEncryption->enable($stream)->then(null, function ($error) use ($stream) { From 4a212fdc8e3edcbccdcbf1ab50c99d0d76898e23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Sat, 19 Mar 2016 14:43:01 +0100 Subject: [PATCH 2/2] Use Travis containers in order to fix IPv6 tests --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c30e934..febe511 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,10 @@ matrix: - php: hhvm-nightly fast_finish: true -before_script: - - composer install --dev --prefer-source +sudo: false + +install: + - composer install script: - phpunit --coverage-text