Skip to content

Commit

Permalink
Merge pull request #116 from clue-labs/no-badssl
Browse files Browse the repository at this point in the history
Update tests to remove defunct badssl.com
  • Loading branch information
cassifyit authored May 28, 2024
2 parents c201994 + e35481d commit 66f1e91
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Clue\React\Socks\Client;
use Clue\React\Socks\Server;
use React\EventLoop\Loop;
use React\Promise\Promise;
use React\Socket\Connector;
use React\Socket\SecureConnector;
use React\Socket\SocketServer;
Expand Down Expand Up @@ -440,28 +441,44 @@ public function testSecureConnectorOkay()
$this->assertResolveStream($ssl->connect('www.google.com:443'));
}

/** @group internet */
public function testSecureConnectorToBadSslWithVerifyFails()
public function testSecureConnectionToTlsServerWithSelfSignedCertificateFailsWithVerifyPeer()
{
if (!function_exists('stream_socket_enable_crypto')) {
$this->markTestSkipped('Required function does not exist in your environment (HHVM?)');
}

$socket = new SocketServer('tls://127.0.0.1:0', array(
'tls' => array(
'local_cert' => __DIR__ . '/../examples/localhost.pem',
)
));
$socket->on('connection', $this->expectCallableNever());

$ssl = new SecureConnector($this->client, null, array('verify_peer' => true));

$this->assertRejectPromise($ssl->connect('self-signed.badssl.com:443'));
$this->assertRejectPromise($ssl->connect($socket->getAddress()));
}

/** @group internet */
public function testSecureConnectorToBadSslWithoutVerifyWorks()
public function testSecureConnectionToTlsServerWithSelfSignedCertificateWorksWithoutVerifyPeer()
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('Not supported on HHVM');
}

$socket = new SocketServer('tls://127.0.0.1:0', array(
'tls' => array(
'local_cert' => __DIR__ . '/../examples/localhost.pem',
)
));
$socket->on('connection', $this->expectCallableOnce());
$promise = new Promise(function ($resolve) use ($socket) {
$socket->on('connection', $resolve);
});

$ssl = new SecureConnector($this->client, null, array('verify_peer' => false));

$this->assertResolveStream($ssl->connect('self-signed.badssl.com:443'));
$this->assertResolveStream($ssl->connect($socket->getAddress()));
$this->assertResolveStream($promise);
}

/** @group internet */
Expand Down

0 comments on commit 66f1e91

Please sign in to comment.