Skip to content

PHPC-1446: Implicitly enable TLS when any TLS-related driver option is set #1054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion php_phongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2720,7 +2720,7 @@ void phongo_manager_init(php_phongo_manager_t* manager, const char* uri_string,
}

#ifdef MONGOC_ENABLE_SSL
if (ssl_opt && mongoc_uri_get_tls(uri)) {
if (ssl_opt) {
mongoc_client_set_ssl_opts(manager->client, ssl_opt);
}
#endif
Expand Down
28 changes: 28 additions & 0 deletions tests/manager/manager-ctor-ssl-003.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
MongoDB\Driver\Manager::__construct(): Specifying a driver option implicitly enables TLS
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php skip_if_not_libmongoc_ssl(['OpenSSL', 'LibreSSL']); ?>
<?php skip_if_ssl(); ?>
--FILE--
<?php

require_once __DIR__ . "/../utils/basic.inc";

// Ensure that the server is up to ensure we're not hitting a different failure below
$manager = new MongoDB\Driver\Manager(URI);
$manager->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(['ping' => 1]));

$manager = new MongoDB\Driver\Manager(URI, [], ['ca_dir' => 'foo']);

echo throws(function () use ($manager) {
// Note that this command will not fail if the server was configured with allowSSL or preferSSL for net.ssl.mode.
$manager->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(['ping' => true]));
}, MongoDB\Driver\Exception\ConnectionTimeoutException::class), "\n";

?>
===DONE===
--EXPECTF--
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException
No suitable servers found (`serverSelectionTryOnce` set): %s
===DONE===