Skip to content

Commit e8ef392

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 ed15101 commit e8ef392

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

206206
The ``X.509`` authentication mechanism uses
207207
:wikipedia:`TLS <Transport_Layer_Security>` with X.509 certificates to
208-
authenticate your user, identified by the distinguished name (DN) of your
209-
client certificate. For more information on determining the *subject* name from
210-
the X.509 certificate, see the MongoDB manual :manual:`X.509 tutorial
211-
</tutorial/configure-x509-client-authentication/#add-x-509-certificate-subject-as-a-user>`.
208+
authenticate by retrieving the distinguished name (DN) from the
209+
client certificate.
212210

213211
You can specify this authentication mechanism by setting the following
214-
parameters of your
215-
:manual:`connection string </reference/connection-string/>`:
212+
parameters of your :manual:`connection string </reference/connection-string/>`:
216213

217-
- Set the ``authMechanism`` parameter to the value ``MONGODB-X509``
218-
- Set the ``tls`` parameter to the value ``true``
214+
- Set the ``authMechanism`` parameter to ``MONGODB-X509``
215+
- Set the ``tls`` parameter to ``true``
219216

220217
Pass the location of your client certificate file as the value of
221218
``tlsCertificateKeyFile`` as a parameter of the connection URI.
222219

223220
.. important::
224-
Always **URI encode** the username and certificate file path using the
225-
``encodeURIComponent`` method to ensure they are correctly parsed.
221+
Always **URI encode** the certificate file path using the
222+
``encodeURIComponent`` method to ensure it is parsed correctly.
226223

227224
.. literalinclude:: /code-snippets/authentication/x509.js
228225
:language: javascript

0 commit comments

Comments
 (0)