summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIsabella Siu <isabella.siu@10gen.com>2019-01-07 17:57:30 -0500
committerIsabella Siu <isabella.siu@10gen.com>2019-01-09 17:57:31 -0500
commit26b05ba269a9313e2fa416b4f7de9429087b767a (patch)
treeab9c1b7be7c3e82600a668034db1477b3d2d3d00 /src
parent39f585b27ba3c872c869f36f3a3fc71e9966724e (diff)
downloadmongo-26b05ba269a9313e2fa416b4f7de9429087b767a.tar.gz
SERVER-37311 add 'tls' alias for 'ssl' in mongo URIs
Diffstat (limited to 'src')
-rw-r--r--src/mongo/client/mongo_uri.cpp6
-rw-r--r--src/mongo/client/mongo_uri_test.cpp5
2 files changed, 8 insertions, 3 deletions
diff --git a/src/mongo/client/mongo_uri.cpp b/src/mongo/client/mongo_uri.cpp
index 18114a03c3f..99468784adb 100644
--- a/src/mongo/client/mongo_uri.cpp
+++ b/src/mongo/client/mongo_uri.cpp
@@ -487,7 +487,9 @@ MongoURI MongoURI::parseImpl(const std::string& url) {
}
transport::ConnectSSLMode sslMode = transport::kGlobalSSLMode;
- auto sslModeIter = options.find("ssl");
+ auto sslModeIter = std::find_if(options.begin(), options.end(), [](auto pred) {
+ return pred.first == "ssl"_sd || pred.first == "tls"_sd;
+ });
if (sslModeIter != options.end()) {
const auto& val = sslModeIter->second;
if (val == "true") {
@@ -495,7 +497,7 @@ MongoURI MongoURI::parseImpl(const std::string& url) {
} else if (val == "false") {
sslMode = transport::kDisableSSL;
} else {
- uasserted(51041, str::stream() << "ssl must be either 'true' or 'false', not" << val);
+ uasserted(51041, str::stream() << "tls must be either 'true' or 'false', not" << val);
}
}
diff --git a/src/mongo/client/mongo_uri_test.cpp b/src/mongo/client/mongo_uri_test.cpp
index 89a14354465..c8136d3198e 100644
--- a/src/mongo/client/mongo_uri_test.cpp
+++ b/src/mongo/client/mongo_uri_test.cpp
@@ -412,6 +412,8 @@ const URITestCase validCases[] = {
{"mongodb://localhost/?ssl=true", "", "", kMaster, "", 1, 1, "", kEnableSSL},
{"mongodb://localhost/?ssl=false", "", "", kMaster, "", 1, 1, "", kDisableSSL},
+ {"mongodb://localhost/?tls=true", "", "", kMaster, "", 1, 1, "", kEnableSSL},
+ {"mongodb://localhost/?tls=false", "", "", kMaster, "", 1, 1, "", kDisableSSL},
};
const InvalidURITestCase invalidCases[] = {
@@ -483,8 +485,9 @@ const InvalidURITestCase invalidCases[] = {
// Missing an entire key-value pair
{"mongodb://127.0.0.1:1234/dbName?foo=a&&c=b"},
- // Illegal value for ssl.
+ // Illegal value for ssl/tls.
{"mongodb://127.0.0.1:1234/dbName?ssl=blah", ErrorCodes::duplicateCodeForTest(51041)},
+ {"mongodb://127.0.0.1:1234/dbName?tls=blah", ErrorCodes::duplicateCodeForTest(51041)},
};
// Helper Method to take a filename for a json file and return the array of tests inside of it