Difficulty when connect using TLS/SSL and verify client certificate #4900
Labels
docs
This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone
NodeJs: 6.9.1
Mongoose version: 4.4.19
MongoDb NodeJs driver version: 2.1.19
A quick checking inside the
connection.js
in master branch seems similar between mine one and the latest one.I have difficulty to configure Mongoose to connect using TLS/SSL and verify server & client certificate but then I manage to figure it out. So something can be improved or at least this page helps the others to configure the same options.
Documentation for
options.auth
is not enough in Connections. Maybe I was wrong but I can't find example like this.My problem is I unable to explicitly define
authMechanism
. Following MongoDb NodeJs native driverauthMechanism
is simply ignored byMongoose
.In the Connections documentation, it just describe options for authentication while in the source code it point to the options for authentication (see http://mongodb.github.com/node-mongodb-native/api-generated/db.html#authenticate). This URI is good to be included in the documentation since I don't have any idea how to construct the
options.auth
without checking the source code.Apparently
options.auth.authMechanism
is the way to go.Simply follow the MongoDb NodeJs native driver URI pattern does not work.
authMechanism
in query string is ignored. MaybeMongoose
can add this?user
in the URLmongodb://user:password@server:27017/db
is not possible for this caseuser
coming from x.509 certificate subject compatible with RFC2253 should be encoded because it contain comma.If I leave it as is, it will throw
MongoError: no valid seed servers in list
because of the comma but if I encode it, it will keep encoded until the MongoDb server complainThere is no x.509 client certificate matching the user
because encoded user does not match with un-encoded one.Muri
should decode theuser
.Mongoose
internally useMuri
to parse theuser
butMuri
does not decode it.user
andpassword
in URI does not support special character and also do not specifyuser
in URL for client certificate.Finally it only works this way:
The text was updated successfully, but these errors were encountered: