|
| 1 | +.. _x509-rotate-member-certs: |
| 2 | + |
| 3 | +================================= |
| 4 | +Rotate X.509 Cluster Certificates |
| 5 | +================================= |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 1 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +.. versionadded:: 7.0 |
| 16 | + |
| 17 | +Cluster members can use X.509 certificates for :ref:`membership |
| 18 | +authentication <internal-auth-x509>` to identify other servers |
| 19 | +in the same deployment. |
| 20 | + |
| 21 | +To identify each other as members, Distinguished Name (DN) values |
| 22 | +for the X.509 certificate of each member must have the same |
| 23 | +Organization (O), Organizational Unit (OU), and Domain Component (DC) |
| 24 | +attributes. Alternatively, the certificates must have the same |
| 25 | +extension value. |
| 26 | + |
| 27 | +Clusters adopting new certificates can use the |
| 28 | +:parameter:`tlsClusterAuthX509Override` parameter to accept X.509 certificates |
| 29 | +with different DN attributes during the certificate rotation procedure. Once |
| 30 | +all members use certificates with the new value, remove the override to begin |
| 31 | +rejecting the now out of date certificates. |
| 32 | + |
| 33 | +.. note:: |
| 34 | + |
| 35 | + To perform a rolling update to rotate certificates on a cluster that doesn't |
| 36 | + use the :setting:`net.tls.clusterAuthX509` settings and won't after the update, |
| 37 | + see :ref:`x509-rolling-update`. |
| 38 | + |
| 39 | +About This Task |
| 40 | +--------------- |
| 41 | + |
| 42 | +Consider a replica set where member certificates |
| 43 | +(set using the :setting:`~net.tls.clusterFile` and |
| 44 | +:setting:`~net.tls.certificateKeyFile` settings) |
| 45 | +have Distinguished Name (DN) values that use the ``10gen`` organization |
| 46 | +and ``10gen Server`` organizational unit (set using the |
| 47 | +:setting:`~net.tls.clusterAuthX509.attributes` setting). |
| 48 | + |
| 49 | +.. code-block:: yaml |
| 50 | + :emphasize-lines: 6, 8, 11 |
| 51 | + |
| 52 | + security: |
| 53 | + clusterAuthMode: x509 |
| 54 | + net: |
| 55 | + tls: |
| 56 | + mode: requireTLS |
| 57 | + certificateKeyFile: /etc/mycerts/10gen-server1.pem |
| 58 | + CAFile: /etc/mycerts/ca.pem |
| 59 | + clusterFile: /etc/mycerts/10gen-cluster1.pem |
| 60 | + clusterCAFile: /etc/mycerts/ca.pem |
| 61 | + clusterAuthX509: |
| 62 | + attributes: O=10gen, OU=10gen Server |
| 63 | + |
| 64 | +This tutorial assumes that the new X.509 certificates meet |
| 65 | +membership certificate and all other requirements and that |
| 66 | +the cluster configuration identifies peer certificates |
| 67 | +using Distinguished Name (DN) values. |
| 68 | +For details, see :ref:`x509-member-certificate-requirements`. |
| 69 | + |
| 70 | +Steps |
| 71 | +----- |
| 72 | + |
| 73 | +These steps update member certificates to use new X.509 certificates on a cluster |
| 74 | +configured with the :setting:`~net.tls.clusterAuthX509.attributes` setting. |
| 75 | + |
| 76 | +The new certificates have Distinguished Names (DN) that change the |
| 77 | +Organization (O) attributes from ``10gen`` to ``MongoDB`` and the |
| 78 | +Organizational Unit (OU) attribute from ``10gen Server`` to ``MongoDB Server``. |
| 79 | + |
| 80 | +.. procedure:: |
| 81 | + |
| 82 | + .. step:: Update the TLS Cluster Membership Configuration |
| 83 | + |
| 84 | + Update the configuration file of each server: |
| 85 | + |
| 86 | + * Change :setting:`~net.tls.clusterAuthX509.attributes` setting to use |
| 87 | + the values on the new certificate |
| 88 | + |
| 89 | + * Set the :parameter:`tlsClusterAuthX509Override` parameter to use the |
| 90 | + DN attributes of the old certificate. |
| 91 | + |
| 92 | + For example: |
| 93 | + |
| 94 | + .. code-block:: yaml |
| 95 | + :emphasize-lines: 9, 13 |
| 96 | + |
| 97 | + net: |
| 98 | + tls: |
| 99 | + mode: requireTLS |
| 100 | + certificateKeyFile: /etc/mycerts/mongodb-server1.pem |
| 101 | + CAFile: /etc/mycerts/ca.pem |
| 102 | + clusterFile: /etc/mycerts/mongodb-cluster1.pem |
| 103 | + clusterCAFile: /etc/mycerts/ca.pem |
| 104 | + clusterAuthX509: |
| 105 | + attributes: O=MongoDB, OU=MongoDB Server |
| 106 | + security: |
| 107 | + clusterAuthMode: x509 |
| 108 | + setParameter: |
| 109 | + tlsClusterAuthX509Override: { attributes: O=10gen, OU=10gen Server } |
| 110 | + |
| 111 | + .. step:: Restart Secondary Cluster Members |
| 112 | + |
| 113 | + .. include:: /includes/procedure-replica-set-restart-secondaries |
| 114 | + |
| 115 | + Secondary servers in the replica set now accept peer connections from |
| 116 | + members using certificates with the new DN attributes. |
| 117 | + |
| 118 | + .. step:: Restart Primary Cluster Member |
| 119 | + |
| 120 | + .. include:: /includes/procedure-replica-set-restart-primary |
| 121 | + |
| 122 | + The primary server in the replica set steps down and restarts as a |
| 123 | + secondary that now accepts peer connections from members using |
| 124 | + certificates with the new DN attributes. |
| 125 | + |
| 126 | + .. step:: Update the TLS Certificates |
| 127 | + |
| 128 | + Update the configuration file of each server: |
| 129 | + |
| 130 | + * Change the :setting:`net.tls.certificateKeyFile` setting to use the |
| 131 | + new certificate. |
| 132 | + |
| 133 | + * Change the :setting:`net.tls.clusterFile` setting to use the |
| 134 | + new certificate. |
| 135 | + |
| 136 | + For example: |
| 137 | + |
| 138 | + .. code-block:: yaml |
| 139 | + :emphasize-lines: 4, 6 |
| 140 | + |
| 141 | + net: |
| 142 | + tls: |
| 143 | + mode: requireTLS |
| 144 | + certificateKeyFile: /etc/mycerts/mongodb-server2.pem |
| 145 | + CAFile: /etc/mycerts/ca.pem |
| 146 | + clusterFile: /etc/mycerts/mongodb-cluster2.pem |
| 147 | + clusterCAFile: /etc/mycerts/ca.pem |
| 148 | + clusterAuthX509: |
| 149 | + attributes: O=MongoDB, OU=MongoDB Server |
| 150 | + security: |
| 151 | + clusterAuthMode: x509 |
| 152 | + setParameter: |
| 153 | + tlsClusterAuthX509Override: { attributes: O=10gen, OU=10gen Server } |
| 154 | + |
| 155 | + |
| 156 | + .. step:: Restart Secondary Cluster Members |
| 157 | + |
| 158 | + .. include:: /includes/procedure-replica-set-restart-secondaries |
| 159 | + |
| 160 | + Secondary servers in the replica set now use the new X.509 certificates. |
| 161 | + |
| 162 | + .. step:: Restart Primary Cluster Member |
| 163 | + |
| 164 | + .. include:: /includes/procedure-replica-set-restart-primary |
| 165 | + |
| 166 | + The primary server in the replica set steps down and restarts as a |
| 167 | + secondary that uses the new X.509 certificate. |
| 168 | + |
| 169 | + .. step:: Remove the DN Certification Override Configuration |
| 170 | + |
| 171 | + With all members of the cluster now using the new X.509 certificate, |
| 172 | + update the configuration file to remove the :setting:`setParameter` |
| 173 | + settings for the :parameter:`tlsClusterAuthX509Override` parameter. |
| 174 | + |
| 175 | + For example: |
| 176 | + |
| 177 | + .. code-block:: yaml |
| 178 | + |
| 179 | + net: |
| 180 | + tls: |
| 181 | + mode: requireTLS |
| 182 | + certificateKeyFile: /etc/mycerts/mongodb-server1.pem |
| 183 | + CAFile: /etc/mycerts/ca.pem |
| 184 | + clusterFile: /etc/mycerts/mongodb-cluster1.pem |
| 185 | + clusterCAFile: /etc/mycerts/ca.pem |
| 186 | + clusterAuthX509: |
| 187 | + attributes: O=MongoDB, OU=MongoDB Server |
| 188 | + security: |
| 189 | + clusterAuthMode: x509 |
| 190 | + |
| 191 | + This ensures that the server doesn't configure the old certificate |
| 192 | + settings on startup. |
| 193 | + |
| 194 | + .. step:: Restart Secondary Cluster Members |
| 195 | + |
| 196 | + .. include:: /includes/procedure-replica-set-restart-secondaries |
| 197 | + |
| 198 | + Secondary servers in the replica set restart and no longer accept |
| 199 | + connections from the old X.509 certificates. |
| 200 | + |
| 201 | + .. step:: Restart Primary Cluster Member |
| 202 | + |
| 203 | + .. include:: /includes/procedure-replica-set-restart-primary |
| 204 | + |
| 205 | + The primary server steps down and restarts as a secondary that no longer |
| 206 | + accepts connections from the old X.509 certificates. |
| 207 | + |
| 208 | +Learn More |
| 209 | +---------- |
| 210 | + |
| 211 | +* :ref:`security-auth-x509` |
| 212 | +* :ref:`x509-internal-authentication` |
| 213 | +* :ref:`upgrade-to-x509-internal-authentication` |
0 commit comments