Skip to content

Commit 4fa4b58

Browse files
committed
DOCSP-44856: x509 authentication fixes (#167)
(cherry picked from commit fc77919)
1 parent 677eeb3 commit 4fa4b58

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

source/fundamentals/authentication.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,22 @@ The ``MONGODB-X509`` authentication mechanism uses Transport Level Security (TLS
282282
with X.509 certificates to authenticate your user, which is identified
283283
by the relative distinguished names (RDNs) of your client certificate.
284284

285-
When you specify this authentication mechanism, the server authenticates
286-
the connection by reading the following files:
285+
When specifying this authentication mechanism, you must provide the
286+
following files:
287287

288288
- A certificate authority (CA) file, which contains one or more
289-
certificate authorities to trust when making a TLS connection
290-
- A certificate key file, which references the client certificate private key
289+
certificate authorities to trust when making a TLS connection.
290+
Before connecting to the server, the driver uses this file to verify that the
291+
server's certificate is from one of the specified certificate authorities.
292+
293+
- A certificate key file, which contains the client certificate
294+
and private key. The driver presents this file to the server to
295+
verify the client.
296+
297+
.. tip::
298+
299+
To learn more about X.509 certificates, see
300+
:manual:`x.509 </core/security-x.509/>` in the {+server+} manual.
291301

292302
To specify the ``MONGODB-X509`` authentication mechanism, set the
293303
``mechanism`` field of your ``Credential`` struct to

source/includes/fundamentals/code-snippets/auth.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ async fn main() -> mongodb::error::Result<()> {
7474

7575
// start-x509
7676
let uri = format!(
77-
"mongodb://<hostname>:<port>/?tlsCAFile={tlsCAFile}&tlsCertificateKeyFile={tlsCertificateKeyFile}",
77+
"mongodb://<hostname>:<port>/?tlsCAFile={tlsCAFile}\
78+
&tlsCertificateKeyFile={tlsCertificateKeyFile}\
79+
&tlsCertificateKeyFilePassword={tlsCertificateKeyFilePassword}",
7880
tlsCAFile = "<path to CA certificate>",
7981
tlsCertificateKeyFile = "<path to private client key>"
8082
);
8183
let mut client_options = ClientOptions::parse(uri).await?;
82-
let x509_cred = Credential::builder().mechanism(AuthMechanism::MongoDbAws).build();
84+
let x509_cred = Credential::builder().mechanism(AuthMechanism::MongoDbX509).build();
8385

8486
client_options.credential = Some(x509_cred);
8587
let client = Client::with_options(client_options)?;

0 commit comments

Comments
 (0)