Skip to content

Commit 35524f6

Browse files
committed
PHP 5.6+ uses new SSL/TLS context options
1 parent e3d41bc commit 35524f6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/SecureConnector.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,17 @@ public function create($host, $port)
2727

2828
$context = $this->context + array(
2929
'SNI_enabled' => true,
30-
'SNI_server_name' => $host,
3130
'peer_name' => $host
3231
);
3332

33+
// legacy PHP < 5.6 ignores peer_name and requires legacy context options instead
34+
if (PHP_VERSION_ID < 50600) {
35+
$context += array(
36+
'SNI_server_name' => $host,
37+
'CN_match' => $host
38+
);
39+
}
40+
3441
return $this->connector->create($host, $port)->then(function (Stream $stream) use ($context) {
3542
// (unencrypted) TCP/IP connection succeeded
3643

0 commit comments

Comments
 (0)