[SERVER-25151] mongo shell and connection string (make "ssl" work if present in the connection uri) Created: 19/Jul/16  Updated: 27/Nov/17  Resolved: 15/Sep/16

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: 3.3.14

Type: Improvement Priority: Major - P3
Reporter: Kay Kim (Inactive) Assignee: Samantha Ritter (Inactive)
Resolution: Done Votes: 0
Labels: bkp
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Documented
is documented by DOCS-8908 mongo shell and connection string (ma... Closed
Related
is related to SERVER-27210 3.4.0 mongo shell unable to connect u... Closed
is related to SERVER-31824 ssl command-line options in the shell... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v3.2
Sprint: Platforms 2016-08-26, Platforms 2016-09-19
Participants:
Linked BF Score: 0

 Description   

I was wondering why with the mongo shell, you cannot include the ssl=true option in the connection string?

the following works

mongo mongodb://<username>:<pwd>@<host1>,<host2>,<host3>/admin?replicaSet=docsfeedback-shard-0  --ssl 

but the following does not

mongo mongodb://<username>:<pwd>@<host1>,<host2>,<host3>/admin?replicaSet=docsfeedback-shard-0&ssl=true



 Comments   
Comment by Githook User [ 15/Sep/16 ]

Author:

{u'username': u'samantharitter', u'name': u'samantharitter', u'email': u'samantha.ritter@10gen.com'}

Message: SERVER-25151 Test that ssl option in the URI is honored by the shell
Branch: master
https://github.com/mongodb/mongo/commit/872bf6a043101ee3fcdc78bfc3643c81c270fd9b

Comment by Githook User [ 13/Sep/16 ]

Author:

{u'username': u'samantharitter', u'name': u'samantharitter', u'email': u'samantha.ritter@10gen.com'}

Message: SERVER-25151 Honor ssl=true/false in URIs in the shell
Branch: master
https://github.com/mongodb/mongo/commit/af0be10862e7a9643586fc2bd1898189a2a6c8cb

Comment by Samantha Ritter (Inactive) [ 13/Sep/16 ]

re-opening to add some tests, which can also cover SERVER-26086

Comment by Samantha Ritter (Inactive) [ 13/Sep/16 ]

Our documentation already discusses the ssl=true/false option in URIs, but it's worth explaining how this will work in the shell.

URIs can be used with the shell in two ways, either on startup on the command line, or from within a shell session:

// command-line
> ./mongo mongodb://localhost:27017/admin?ssl=false
 
// within a session
shell> var conn = new Mongo("mongodb://localhost:27017/admin?ssl=true");

To use ssl=true, the shell must have been started with the --ssl command-line option, like so:

// command line
> ./mongo --ssl mongodb://localhost:27017/admin?ssl=true
 
// within a shell session
> ./mongo --ssl
shell> var conn = new Mongo("mongodb://localhost:27017/admin?ssl=true");
 
// this will fail
> ./mongo
shell> var conn = new Mongo("mongodb://localhost:27017/admin?ssl=true");

If a URI does not set ssl=true/false explicitly, the SSL options for that connection will default to the shell's startup options.

> ./mongo --ssl
// this shell session's connection uses ssl
// conn will also use ssl
shell> var conn = new Mongo("mongodb://localhost:27017/admin");
// conn2 will NOT use ssl
shell> var conn2 = new Mongo("mongodb://localhost:27017/admin?ssl=false");

> ./mongo --ssl mongodb://localhost:27017/admin?ssl=false
// this shell session's connection does NOT use ssl, but ssl is configured in the global shell options from the command line argument
// conn WILL use ssl
shell> var conn = new Mongo("mongodb://localhost:27017/admin");
// conn2 will NOT use ssl
shell> var conn2 = new Mongo("mongodb://localhost:27017/admin?ssl=false");

Comment by Bernie Hackett [ 19/Jul/16 ]

This would seem to be a problem for Atlas, since the URL provided for connection includes the ssl option.

Generated at Thu Feb 08 04:08:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.