|
| 1 | +--TEST-- |
| 2 | +Connect to MongoDB with SSL and cert verification error (URI options) |
| 3 | +--SKIPIF-- |
| 4 | +<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?> |
| 5 | +<?php skip_if_not_libmongoc_ssl(); ?> |
| 6 | +<?php skip_if_not_ssl(); ?> |
| 7 | +--FILE-- |
| 8 | +<?php |
| 9 | +require_once __DIR__ . "/../utils/basic.inc"; |
| 10 | + |
| 11 | +$uriOptions = [ |
| 12 | + // libmongoc does not allow the hostname to be overridden as "server" |
| 13 | + 'tlsAllowInvalidHostnames' => true, |
| 14 | + 'tlsAllowInvalidCertificates' => false, |
| 15 | +]; |
| 16 | + |
| 17 | +echo throws(function() use ($uriOptions) { |
| 18 | + $manager = create_test_manager(URI, $uriOptions); |
| 19 | + $cursor = $manager->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(['ping' => 1])); |
| 20 | + var_dump($cursor->toArray()[0]); |
| 21 | +}, MongoDB\Driver\Exception\ConnectionException::class, 'executeCommand'), "\n"; |
| 22 | + |
| 23 | +?> |
| 24 | +===DONE=== |
| 25 | +<?php exit(0); ?> |
| 26 | +--EXPECTF-- |
| 27 | +OK: Got MongoDB\Driver\Exception\ConnectionException thrown from executeCommand |
| 28 | +%sTLS handshake failed%s |
| 29 | +===DONE=== |
0 commit comments