Appendix C - OpenSSL Client Certificates for Testing¶
Warning
Disclaimer
This page is provided for :red:`testing purposes` only and the certificates are for :red:`testing purposes only`.
The following tutorial provides some basic steps for creating :red:`test` x.509 certificates.
- Do not use these certificates for production. Instead, follow your security policies.
- For information on OpenSSL, refer to the official OpenSSL docs. Although this tutorial uses OpenSSL, the material should not be taken as an authoritative reference on OpenSSL.
Prerequisite¶
The procedure outlined on this page uses the :red:`test` intermediate authority
certificate and key mongodb-test-ia.crt
and
mongodb-test-ia.key
created in
Appendix A - OpenSSL CA Certificate for Testing.
Procedure¶
The following procedure outlines the steps to create :red:`test` certificates for MongoDB clients. For steps to create :red:`test` certificates for MongoDB servers, see Appendix B - OpenSSL Server Certificates for Testing.
A. Create the OpenSSL Configuration File¶
Create a :red:`test` configuration file
openssl-test-client.cnf
for your client with the following content:Optional. You can update the default Distinguished Name (DN) values. Ensure that client certificates differ from server certificates with regards to at least one of the following attributes: Organization (
O
), the Organizational Unit (OU
) or the Domain Component (DC
).
B. Generate the Test PEM File for Client¶
Create the :red:`test` key file
mongodb-test-client.key
.Create the :red:`test` certificate signing request
mongodb-test-client.csr
. When asked for Distinguished Name values, enter the appropriate values for your :red:`test` certificate:Important
The client certificate subject must differ to a server certificate subject with regards to at least one of the following attributes: Organization (O), the Organizational Unit (OU) or the Domain Component (DC).
Create the :red:`test` client certificate
mongodb-test-client.crt
.Create the :red:`test` PEM file for the client.
You can use the :red:`test` PEM file to configure
mongosh
for TLS/SSL :red:`testing`. For example, to connect to amongod
or amongos
:Example
For MongoDB 4.2 or greater, include the following options for the client:
Example
For MongoDB 4.0 and earlier**, include the following options for the client:
- On macOS,
If you are :red:`testing` with Keychain Access to manage certificates, create a PKCS 12 file to add to Keychain Access instead of a PEM file:
Once added to Keychain Access, instead of specifying the Certificate Key file, you can use the
--tlsCertificateSelector
to specify the certificate to use. If the CA file is also in Keychain Access, you can omit--tlsCAFile
as well as in the following example:For MongoDB 4.2 or greater
Although still available,
--ssl
and--sslCertificateSelector
are deprecated as of MongoDB 4.2.For MongoDB 4.0 and earlier
For adding certificates to Keychain Access, refer to your official documentation for Keychain Access.