Skip to content

Commit 40939c7

Browse files
authored
DOCSP-18653: remove username from x509 example (#640)
* DOCSP-18653: remove username from x509 example * CC suggestions
1 parent 654028e commit 40939c7

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
@@ -244,24 +244,21 @@ The driver checks for your credentials in the following sources in order:
244244

245245
The ``X.509`` authentication mechanism uses
246246
:wikipedia:`TLS <Transport_Layer_Security>` with X.509 certificates to
247-
authenticate your user, identified by the distinguished name (DN) of your
248-
client certificate. For more information on determining the *subject* name from
249-
the X.509 certificate, see the MongoDB manual :manual:`X.509 tutorial
250-
</tutorial/configure-x509-client-authentication/#add-x-509-certificate-subject-as-a-user>`.
247+
authenticate by retrieving the distinguished name (DN) from the
248+
client certificate.
251249

252250
You can specify this authentication mechanism by setting the following
253-
parameters of your
254-
:manual:`connection string </reference/connection-string/>`:
251+
parameters of your :manual:`connection string </reference/connection-string/>`:
255252

256-
- Set the ``authMechanism`` parameter to the value ``MONGODB-X509``
257-
- Set the ``tls`` parameter to the value ``true``
253+
- Set the ``authMechanism`` parameter to ``MONGODB-X509``
254+
- Set the ``tls`` parameter to ``true``
258255

259256
Pass the location of your client certificate file as the value of
260257
``tlsCertificateKeyFile`` as a parameter of the connection URI.
261258

262259
.. important::
263-
Always **URI encode** the username and certificate file path using the
264-
``encodeURIComponent`` method to ensure they are correctly parsed.
260+
Always **URI encode** the certificate file path using the
261+
``encodeURIComponent`` method to ensure it is parsed correctly.
265262

266263
.. literalinclude:: /code-snippets/authentication/x509.js
267264
:language: javascript

0 commit comments

Comments
 (0)