File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
includes/fundamentals/code-snippets Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -282,12 +282,22 @@ The ``MONGODB-X509`` authentication mechanism uses Transport Level Security (TLS
282
282
with X.509 certificates to authenticate your user, which is identified
283
283
by the relative distinguished names (RDNs) of your client certificate.
284
284
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:
287
287
288
288
- 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.
291
301
292
302
To specify the ``MONGODB-X509`` authentication mechanism, set the
293
303
``mechanism`` field of your ``Credential`` struct to
Original file line number Diff line number Diff line change @@ -74,13 +74,15 @@ async fn main() -> mongodb::error::Result<()> {
74
74
75
75
// start-x509
76
76
let uri = format ! (
77
- "mongodb://<hostname>:<port>/?tlsCAFile={tlsCAFile}&tlsCertificateKeyFile={tlsCertificateKeyFile}" ,
77
+ "mongodb://<hostname>:<port>/?tlsCAFile={tlsCAFile}\
78
+ &tlsCertificateKeyFile={tlsCertificateKeyFile}\
79
+ &tlsCertificateKeyFilePassword={tlsCertificateKeyFilePassword}",
78
80
tlsCAFile = "<path to CA certificate>" ,
79
81
tlsCertificateKeyFile = "<path to private client key>" ,
80
82
tlsCertificateKeyFilePassword = "<password for client key>"
81
83
) ;
82
84
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 ( ) ;
84
86
85
87
client_options. credential = Some ( x509_cred) ;
86
88
let client = Client :: with_options ( client_options) ?;
You can’t perform that action at this time.
0 commit comments