Skip to content

Commit 9635d62

Browse files
Merge pull request #206 from nvillahermosa-mdb/DOCSP-46979-x509-connection
DOCSP-46979 X509 authentication
2 parents 27c06e6 + 4b6c1d0 commit 9635d62

File tree

4 files changed

+89
-25
lines changed

4 files changed

+89
-25
lines changed

source/connection-strings/mongodb-database-connection-strings.txt

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ MongoDB Database Connection Strings
1515
This page describes the Uniform Resource Identifier (URI) formats for defining
1616
connections to your MongoDB database.
1717

18-
Relational Migrator supports all connection string options except
19-
:urioption:`appName`. It overrides ``appName`` when connecting to your MongoDB
20-
deployment. For details on MongoDB connection string options, see
21-
:manual:`Connection Strings <mongodb-uri>`.
18+
Relational Migrator supports all :manual:`MongoDB connection string options
19+
</reference/connection-string-options/>` except :urioption:`appName`. It
20+
overrides ``appName`` when connecting to your MongoDB deployment.
2221

23-
MongoDB User
24-
------------
22+
.. important::
2523

26-
For both Atlas and on-premises deployments, create a separate
27-
:ref:`MongoDB user <rm-mongodb-service-user>` for Relational Migrator with
28-
:authrole:`readWrite` access to your MongoDB database.
24+
For both Atlas and on-premises deployments, create a separate
25+
:ref:`MongoDB user <rm-mongodb-service-user>` for Relational Migrator with
26+
:authrole:`readWrite` access to your MongoDB database.
2927

3028
Atlas Connection URI
3129
--------------------
@@ -34,12 +32,12 @@ Atlas Connection URI
3432

3533
mongodb+srv://username:[email protected]/database
3634

37-
For example, to use an account named ``migrator-service`` to connect to the
38-
``MongoEnterprises`` database:
35+
For example, to use an account named ``migrator-service`` with password
36+
``hunter2`` to connect to the ``MongoEnterprises`` database:
3937

4038
.. code-block::
4139

42-
mongodb+srv://migrator-service:[email protected].mongodb.net/MongoEnterprises
40+
mongodb+srv://migrator-service:[email protected].mongodb.net/MongoEnterprises
4341

4442
On-Premises Connection URI
4543
--------------------------
@@ -48,9 +46,66 @@ On-Premises Connection URI
4846

4947
mongodb://username:password@host:port/database
5048

51-
For example, to use an account named ``migrator-service`` to connect to the
52-
``MongoEnterprises`` database:
49+
For example, to use an account named ``migrator-service`` with password
50+
``hunter2`` to connect to the ``MongoEnterprises`` database:
5351

5452
.. code-block::
5553

56-
mongodb://migrator-service:password@localhost:27017/MongoEnterprises
54+
mongodb://migrator-service:hunter2@localhost:27017/MongoEnterprises
55+
56+
.. _rm-x509-auth:
57+
58+
Using X.509 Authentication
59+
---------------------------
60+
61+
To connect to MongoDB using X.509 authentication, omit a username and password.
62+
Instead, specify the on-premises host and port or the Atlas cluster URL and set
63+
the following options:
64+
65+
.. code-block::
66+
67+
<on-premises host:port or clusterurl.mongodb.net>?authSource=$external&authMechanism=MONGODB-X509&tlsCertificateKeyFile=/path/to/cert/client.p12&tlsCertificateKeyFilePassword=certpassword
68+
69+
70+
.. list-table::
71+
:header-rows: 1
72+
73+
* - Option
74+
- Value
75+
76+
* - :urioption:`authSource`
77+
- ``$external``
78+
79+
* - :urioption:`authMechanism`
80+
- ``MONGODB-X509``
81+
82+
* - :urioption:`tlsCertificateKeyFile`
83+
- The path to the ``.p12`` file that contains the certificate and key to
84+
present to the mongod or mongos instance.
85+
86+
:gold:`IMPORTANT:` Unlike other MongoDB products, Relational Migrator
87+
requires a path to a ``.p12`` file, not a ``.pem`` file. If your
88+
certificate is saved as a ``.pem`` file, you can convert it using a tool
89+
like OpenSSL's `PKCS12 command <https://docs.openssl.org/master/man1/openssl-pkcs12/>`__:
90+
91+
.. code-block:: bash
92+
:copyable: true
93+
94+
openssl pkcs12 -export -inkey cert_key_pem.txt -in cert_key.pem -out
95+
cert_key.p12
96+
97+
* - :urioption:`tlsCertificateKeyFilePassword`
98+
- The password to de-crypt the ``.p12`` file.
99+
100+
* - :urioption:`tlsCAFile`
101+
- Required only if the MongoDB instance has a TLS/SSL setup with its own public
102+
key infrastructure. The path to the local ``.pem`` file that contains
103+
the root certificate chain from the Certificate Authority.
104+
105+
For example, to connect to the ``MongoEnterprises`` database on
106+
``cluster1.abc123.mongodb.net``, using the certificate file
107+
``/etc/ssl/caToValidateServerCertificates.p12`` with the password ``verysecure``:
108+
109+
.. code-block::
110+
111+
mongodb+srv://cluster1.abc123.mongodb.net/MongoEnterprises?authSource=$external&authMechanism=MONGODB-X509&tlsCertificateKeyFile=/etc/ssl/caToValidateServerCertificates.p12&tlsCertificateKeyFilePassword=verysecure

source/database-connections/save-mongodb-connection.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@ To save a new connection from the :guilabel:`Connections` page:
4646
.. step:: Enter the MongoDB connection string
4747

4848
a. In :guilabel:`MongoDB connection string (URI)`, enter
49-
your :manual:`MongoDB URI <mongodb-uri>`.
49+
your :manual:`MongoDB URI </reference/connection-string>`.
50+
51+
If you're using :ref:`X.509 authentication <rm-x509-auth>`, Relational
52+
Migrator verifies the connection string syntax and the certificate file format.
5053

5154
#. If it isn't included in the connection string, enter the
5255
:guilabel:`Database` to connect to.
5356

54-
#. If they aren't included in the connection string, enter the
55-
:guilabel:`Username` and :guilabel:`Password` of your
56-
:ref:`Relational Migrator MongoDB user <rm-mongodb-service-user>`.
57+
#. If they aren't included in the connection string and you aren't using
58+
X.509 authentication, enter the :guilabel:`Username` and
59+
:guilabel:`Password` of your :ref:`Relational Migrator MongoDB user
60+
<rm-mongodb-service-user>`.
5761

5862
Checking :guilabel:`Save password` saves the password securely
5963
on your machine, so you don't have to enter the :guilabel:`Username`

source/includes/steps-atlas-cluster.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
If you are using MongoDB Atlas, you can select your Atlas cluster
66
from the :guilabel:`Select a cluster` list, or you can enter the
7-
:manual:`connection string <mongodb-uri>`.
7+
:manual:`connection string </reference/connection-string>`.
88

99
If you are using an on-premises deployment, you must use the MongoDB
1010
connection string.
@@ -39,7 +39,7 @@ connection string.
3939
:tabid: enter-mongodb-uri
4040

4141
a. In the :guilabel:`MongoDB connection string (URI)` field, input
42-
your :manual:`MongoDB URI <mongodb-uri>`.
42+
your :manual:`MongoDB URI </reference/connection-string>`.
4343

4444
#. If it isn't included in the connection string, enter the
4545
:guilabel:`Database` to connect to.

source/includes/steps-create-mongodb-connection-short.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
a. Enter the MongoDB connection string.
44

55
a. In :guilabel:`MongoDB connection string (URI)`, enter
6-
your :manual:`MongoDB URI <mongodb-uri>`.
6+
your :manual:`MongoDB URI </reference/connection-string>`.
7+
8+
If you're using :ref:`X.509 authentication <rm-x509-auth>`, Relational
9+
Migrator verifies the connection string syntax and the certificate file
10+
format.
711

812
#. If it isn't included in the connection string, enter the
913
:guilabel:`Database` to connect to.
1014

11-
#. If they aren't included in the connection string, enter the
12-
:guilabel:`Username` and :guilabel:`Password` of your
13-
:ref:`Relational Migrator MongoDB user <rm-mongodb-service-user>`.
15+
#. If they aren't included in the connection string and you aren't using
16+
X.509 authentication, enter the :guilabel:`Username` and
17+
:guilabel:`Password` of your :ref:`Relational Migrator MongoDB user
18+
<rm-mongodb-service-user>`.
1419

1520
#. Enter a :guilabel:`Connection name` and optional :guilabel:`Environment tag`.
1621

0 commit comments

Comments
 (0)