From 56499a224c1958b70adb03288387fc17447b1b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Wed, 13 Apr 2016 15:23:36 +0200 Subject: [PATCH] Demonstrate Server Name Indication (SNI) issues --- tests/IntegrationTest.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index 9e16281..a22caf9 100644 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -56,6 +56,37 @@ public function gettingEncryptedStuffFromGoogleShouldWork() $this->assertRegExp('#^HTTP/1\.0#', $response); } + /** @test */ + public function gettingEncryptedStuffFromHostWithSniShouldWork() + { + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('Not supported on HHVM'); + } + + $loop = new StreamSelectLoop(); + + $factory = new Factory(); + $dns = $factory->create('8.8.8.8', $loop); + + $connected = false; + $response = null; + + $secureConnector = new SecureConnector( + new Connector($loop, $dns), + $loop + ); + + $conn = Block\await($secureConnector->create('reactphp.sni.velox.ch', 443), $loop); + + $conn->write("GET / HTTP/1.0\r\nHost: reactphp.sni.velox.ch\r\n\r\n"); + + $response = Block\await(BufferedSink::createPromise($conn), $loop); + + $this->assertRegExp('#^HTTP/1\.[01] 2\d\d#', $response); + $this->assertRegExp('#reactphp\.sni\.velox\.ch#', $response); + $this->assertRegExp('#CN=\*\.sni\.velox\.ch#', $response); + } + /** @test */ public function testSelfSignedRejectsIfVerificationIsEnabled() {