Skip to content

Commit 8b2d9c0

Browse files
committed
DOCSP-18653: remove username from x509 example (#640)
* DOCSP-18653: remove username from x509 example * CC suggestions (cherry picked from commit 40939c7)
1 parent 5ef96f4 commit 8b2d9c0

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

source/code-snippets/authentication/x509.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
const { MongoClient } = require("mongodb");
22

33
// Replace the following with values for your environment.
4-
const username = encodeURIComponent("<client certificate distinguished name>");
54
const clusterUrl = "<MongoDB cluster url>";
65
const clientPEMFile = encodeURIComponent("<path to the client pem certificate file>");
76

87
const authMechanism = "MONGODB-X509";
98

109
// Replace the following with your MongoDB deployment's connection string.
1110
const uri =
12-
`mongodb+srv://${username}@${clusterUrl}/?authMechanism=${authMechanism}&tls=true&tlsCertificateKeyFile=${clientPEMFile}`;
11+
`mongodb+srv://${clusterUrl}/?authMechanism=${authMechanism}&tls=true&tlsCertificateKeyFile=${clientPEMFile}`;
1312

1413
// Create a new MongoClient
1514
const client = new MongoClient(uri);

source/fundamentals/authentication/mechanisms.txt

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,21 @@ The driver checks for your credentials in the following sources in order:
210210

211211
The ``X.509`` authentication mechanism uses
212212
:wikipedia:`TLS <Transport_Layer_Security>` with X.509 certificates to
213-
authenticate your user, identified by the distinguished name (DN) of your
214-
client certificate. For more information on determining the *subject* name from
215-
the X.509 certificate, see the MongoDB manual :manual:`X.509 tutorial
216-
</tutorial/configure-x509-client-authentication/#add-x-509-certificate-subject-as-a-user>`.
213+
authenticate by retrieving the distinguished name (DN) from the
214+
client certificate.
217215

218216
You can specify this authentication mechanism by setting the following
219-
parameters of your
220-
:manual:`connection string </reference/connection-string/>`:
217+
parameters of your :manual:`connection string </reference/connection-string/>`:
221218

222-
- Set the ``authMechanism`` parameter to the value ``MONGODB-X509``
223-
- Set the ``tls`` parameter to the value ``true``
219+
- Set the ``authMechanism`` parameter to ``MONGODB-X509``
220+
- Set the ``tls`` parameter to ``true``
224221

225222
Pass the location of your client certificate file as the value of
226223
``tlsCertificateKeyFile`` as a parameter of the connection URI.
227224

228225
.. important::
229-
Always **URI encode** the username and certificate file path using the
230-
``encodeURIComponent`` method to ensure they are correctly parsed.
226+
Always **URI encode** the certificate file path using the
227+
``encodeURIComponent`` method to ensure it is parsed correctly.
231228

232229
.. literalinclude:: /code-snippets/authentication/x509.js
233230
:language: javascript

0 commit comments

Comments
 (0)