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
282282with X.509 certificates to authenticate your user, which is identified
283283by 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
292302To specify the ``MONGODB-X509`` authentication mechanism, set the
293303``mechanism`` field of your ``Credential`` struct to
Original file line number Diff line number Diff 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) ?;
You can’t perform that action at this time.
0 commit comments