|
| 1 | +.. _kafka-configure-ssl: |
| 2 | + |
1 | 3 | ==============================
|
2 | 4 | SSL/TLS and X.509 Certificates
|
3 | 5 | ==============================
|
4 | 6 |
|
5 |
| -TODO: |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 2 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +Overview |
| 16 | +-------- |
| 17 | + |
| 18 | +In this guide, you can learn how to secure communications between your |
| 19 | +{+mkc+} worker and your MongoDB cluster. |
| 20 | + |
| 21 | +To secure your connection, you must perform the following tasks: |
| 22 | + |
| 23 | +- :ref:`Create the certificates <prerequisites-mkc>` |
| 24 | +- :ref:`Store the certificates on the worker host machine <key-store-trust-store-setup-mkc>` |
| 25 | +- :ref:`Supply the certificates' credentials to the connector <supply-credentials-to-mkc>` |
| 26 | + |
| 27 | +.. note:: |
| 28 | + |
| 29 | + If you host your MongoDB cluster on :atlas:`MongoDB Atlas </>` or |
| 30 | + your cluster does not explicitly require certificates, you can |
| 31 | + already communicate securely and do not need to follow the steps in |
| 32 | + this guide. |
| 33 | + |
| 34 | +.. _prerequisites-mkc: |
| 35 | + |
| 36 | +Prerequisites |
| 37 | +------------- |
| 38 | + |
| 39 | +This guide requires prior knowledge of the following concepts: |
| 40 | + |
| 41 | +- :wikipedia:`Transport Layer Security <Transport_Layer_Security>` |
| 42 | +- :wikipedia:`X.509 <x.509>` |
| 43 | +- :wikipedia:`Certificate Authorities (CA) <Certificate_authority>` |
| 44 | +- :wikipedia:`PKCS 12 <PKCS_12>` |
| 45 | +- `OpenSSL <https://www.openssl.org/>`__ |
| 46 | +- `keytool <https://docs.oracle.com/en/java/javase/12/tools/keytool.html>`__ |
| 47 | + |
| 48 | +.. _key-store-trust-store-setup-mkc: |
| 49 | + |
| 50 | +Store Certificates on the Worker |
| 51 | +-------------------------------- |
| 52 | + |
| 53 | +Store your certificates in a **keystore** and **truststore** to secure |
| 54 | +your certificate credentials for each server you run your {+mkc+} worker |
| 55 | +instance on. |
| 56 | + |
| 57 | +Keystore |
| 58 | +~~~~~~~~ |
| 59 | + |
| 60 | +You can use a keystore to store private keys and identity certificates. |
| 61 | +The keystore uses the key and certificate to verify the client's |
| 62 | +identity to external hosts. |
| 63 | + |
| 64 | +If your SSL/TLS configuration requires a client certificate to connect |
| 65 | +to your worker instance, generate a secure private key and include the |
| 66 | +client certificate bundled with the intermediate CA. Then, store this |
| 67 | +information in your keystore by using the following ``openssl`` command |
| 68 | +to generate a PKCS 12 file: |
| 69 | + |
| 70 | +.. code-block:: bash |
| 71 | + |
| 72 | + openssl pkcs12 -export -inkey <your private key> \ |
| 73 | + -in <your bundled certificate> \ |
| 74 | + -out <your output pkcs12 file> |
| 75 | + |
| 76 | +Truststore |
| 77 | +~~~~~~~~~~ |
| 78 | + |
| 79 | +You can use a truststore to store certificates from a CA. The truststore |
| 80 | +uses the certificates to identify parties the client trusts. Some |
| 81 | +examples of these certificates are a root CA, intermediate CA and your |
| 82 | +MongoDB cluster's end entity certificate. |
| 83 | + |
| 84 | +Import the certificates of parties that you trust into your truststore |
| 85 | +by using the following ``keytool`` command: |
| 86 | + |
| 87 | +.. code-block:: bash |
| 88 | + |
| 89 | + keytool -import -trustcacerts -import -file <your root or intermediate CA> |
| 90 | + |
| 91 | +If your SSL/TLS configuration requires the end entity certificate for your |
| 92 | +MongoDB cluster, import it into your truststore with the following |
| 93 | +command: |
| 94 | + |
| 95 | +.. code-block:: bash |
| 96 | + |
| 97 | + keytool -import -file <your server bundled certificate> -keystore <your keystore name> |
| 98 | + |
| 99 | +For more information on how to set up a client keystore and truststore for |
| 100 | +testing purposes, see |
| 101 | +:manual:`OpenSSL Client Certificates for Testing </appendix/security/appendixC-openssl-client/#appendix-c-openssl-client-certificates-for-testing>`. |
| 102 | + |
| 103 | +.. _supply-credentials-to-mkc: |
| 104 | + |
| 105 | +Add Credentials to the Connector |
| 106 | +-------------------------------- |
| 107 | + |
| 108 | +The {+mkc+} worker processes JVM options from your ``KAFKA_OPTS`` |
| 109 | +environment variable. The environment variable contains the path and |
| 110 | +password to your keystore and truststore. |
| 111 | + |
| 112 | +Export the following JVM options in your ``KAFKA_OPTS`` variable: |
| 113 | + |
| 114 | +.. code-block:: bash |
| 115 | + |
| 116 | + export KAFKA_OPTS="\ |
| 117 | + -Djavax.net.ssl.trustStore=<your path to truststore> \ |
| 118 | + -Djavax.net.ssl.trustStorePassword=<your truststore password> \ |
| 119 | + -Djavax.net.ssl.keyStore=<your path to keystore> \ |
| 120 | + -Djavax.net.ssl.keyStorePassword=<your keystore password>" |
| 121 | + |
| 122 | +When the worker processes the JVM options, the connector attempts to |
| 123 | +connect by using the SSL/TLS protocol and certificates in your keystore |
| 124 | +and truststore. |
0 commit comments