You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Docs/reference/content/reference/driver/authentication.md
+79-42Lines changed: 79 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,34 +52,71 @@ In .NET Standard, authenticating via SCRAM-SHA-256 may not work with non-ASCII p
52
52
53
53
### x.509 Authentication
54
54
55
-
The [x.509](http://docs.mongodb.org/manual/core/authentication/#x-509-certificate-authentication) mechanism authenticates a user whose name is derived from the distinguished subject name of the x.509 certificate presented by the driver during SSL negotiation. This authentication method requires the use of [SSL connections]({{< relref "reference\driver\ssl.md" >}}) with certificate validation and is available in MongoDB 2.6 and newer. To create a credential of this type, use the following static factory method:
55
+
The [x.509](http://docs.mongodb.org/manual/core/authentication/#x-509-certificate-authentication) mechanism authenticates a user whose name is derived from the distinguished subject name of the x.509 certificate presented by the driver during SSL negotiation. This authentication method requires the use of [SSL connections]({{< relref "reference\driver\ssl.md" >}}) with certificate validation and is available in MongoDB 2.6 and newer.
Whenconfiguringx.509authenticationprogrammatically, the `username` parameterprovidedto `CreateX509Credential` mustmatchthedistinguishedsubjectnameofyourx.509certificate*exactly*. Todeterminetheexact `username` requiredfor your x.509 connection, consult [the MongoDB server x.509 tutorial](http://docs.mongodb.org/manual/tutorial/configure-x509-client-authentication/#add-x-509-certificate-subject-as-a-user). Alternatively, any `null` `username` parameter provided to `CreateX509Credential` will cause the MongoDB server to infer a username based on the distinguished subject name of the x.509 certificate. Using a `null` username value can help prevent issues when certificates are updated, since you can avoid managing a `username` value and a certificate as separate entities in your environment.
66
+
67
+
68
+
2. Manually, using [connection string options](https://docs.mongodb.com/manual/reference/connection-string/#connection-string-options):
69
+
70
+
```
71
+
mongodb://myserver/?authMechanism=MONGODB-X509
72
+
```
73
+
74
+
When configuring x.509 authentication from a connectionstring, youmuststillprovidethecertificateprogrammaticallyvia `MongoClientSettings`. Anyconnectionstringspecifyingx.509 authenticationmustbeimportedintoa `MongoClientSettings` objectusing `MongoClientSettings.FromConnectionString` toaddthecertificatetotheconfiguration.
75
+
76
+
Youcanusecertificatesviathetruststoresonyourcomputer, oraPKCS #12 (`.pfx`) file. Tobeusedwithclientauthentication, the [`X509Certificate`]({{<msdnref"system.security.cryptography.x509certificates.x509certificate">}}) providedtothedrivermustcontainthe [`PrivateKey`]({{<msdnref"system.security.cryptography.x509certificates.x509certificate2.privatekey">}}).
77
+
78
+
Fortestingpurposes, the `AllowInsecureTls` fieldofyour `MongoClientSettings` canbesetto `true` toallowtheuseofself-signedcertificates. Sincethissettingbypassesthevalidationofcertificatesentirely, itshouldneverbeusedfor production uses.
66
79
67
-
Even when using the connection string to provide the credential, the certificate must still be provided via code. This certificate can be pulled out of the trust stores on the box, or from a file. However, to be used with client authentication, the [`X509Certificate`]({{< msdnref "system.security.cryptography.x509certificates.x509certificate" >}}) provided to the driver must contain the [`PrivateKey`]({{< msdnref "system.security.cryptography.x509certificates.x509certificate2.privatekey" >}}).
80
+
Connecting using a `MongoClientSettings` object built from a connection string:
Depending on the kerberos setup, it may be required to specify some additional properties. These may be specified in the connection string or via code.
115
152
116
153
-**CANONICALIZE_HOST_NAME**
117
-
118
-
Uses the DNS server to retrieve the fully qualified domain name (FQDN) of the host.
0 commit comments