Skip to content

Commit 663f29f

Browse files
committed
DOCSP-44856: x509 authentication fixes (#167)
(cherry picked from commit fc77919)
1 parent 10cca36 commit 663f29f

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,13 +74,15 @@ 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
tlsCertificateKeyFilePassword = "<password for client key>"
8183
);
8284
let mut client_options = ClientOptions::parse(uri).await?;
83-
let x509_cred = Credential::builder().mechanism(AuthMechanism::MongoDbAws).build();
85+
let x509_cred = Credential::builder().mechanism(AuthMechanism::MongoDbX509).build();
8486

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

0 commit comments

Comments
 (0)