|
| 1 | +--- |
| 2 | +Title: Certificate-based authentication |
| 3 | +alwaysopen: false |
| 4 | +categories: |
| 5 | +- docs |
| 6 | +- operate |
| 7 | +- rs |
| 8 | +description: Certificate-based authentication allows secure, passwordless access to the REST API and databases. |
| 9 | +linkTitle: Certificate-based authentication |
| 10 | +weight: 70 |
| 11 | +--- |
| 12 | + |
| 13 | +You can set up certificate-based authentication for specific users to enable secure, passwordless access to the Redis Enterprise Software [REST API]({{<relref "/operate/rs/references/rest-api">}}) and databases. |
| 14 | + |
| 15 | +## Set up certificate-based authentication |
| 16 | + |
| 17 | +To set up certificate-based authentication: |
| 18 | + |
| 19 | +1. [Add the `mtls_trusted_ca` certificate.](#add-cert) |
| 20 | + |
| 21 | +1. [Configure cluster settings.](#config-cluster) |
| 22 | + |
| 23 | +1. If you want to enable certificate-based authentication for databases, you must [enable mutual TLS for the relevant databases](#enable-mtls-dbs). Otherwise, you can skip this step. |
| 24 | + |
| 25 | +1. [Create certificate auth_method users.](#create-cert-users) |
| 26 | + |
| 27 | +### Add mtls_trusted_ca certificate {#add-cert} |
| 28 | + |
| 29 | +Add a trusted CA certificate `mtls_trusted_ca` to the cluster using an [update cluster certificate]({{<relref "/operate/rs/references/rest-api/requests/cluster/certificates#put-cluster-update_cert">}}) request: |
| 30 | + |
| 31 | +```sh |
| 32 | +PUT /v1/cluster/update_cert |
| 33 | +{ |
| 34 | + "name": "mtls_trusted_ca", |
| 35 | + "certificate": "<content of certificate PEM file>" |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +### Configure cluster settings {#config-cluster} |
| 40 | + |
| 41 | +[Update cluster settings]({{<relref "/operate/rs/references/rest-api/requests/cluster#put-cluster">}}) with mutual TLS configuration. |
| 42 | + |
| 43 | +For certificate validation by Subject Alternative Name (SAN), use: |
| 44 | + |
| 45 | +```sh |
| 46 | +PUT /v1/cluster |
| 47 | +{ |
| 48 | + "mtls_certificate_authentication": true, |
| 49 | + "mtls_client_cert_subject_validation_type": "san_cn", |
| 50 | + "mtls_authorized_subjects": [{ |
| 51 | + "CN": "<Common Name>" |
| 52 | + }] |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +For certificate validation by full Subject Name, use: |
| 57 | + |
| 58 | +```sh |
| 59 | +PUT /v1/cluster |
| 60 | +{ |
| 61 | + "mtls_certificate_authentication": true, |
| 62 | + "mtls_client_cert_subject_validation_type": "full_subject", |
| 63 | + "mtls_authorized_subjects": [{ |
| 64 | + "CN": "<Common Name>", |
| 65 | + "OU": [<array of Organizational Unit strings>], |
| 66 | + "O": "<Organization>", |
| 67 | + "C": "<2-letter country code>", |
| 68 | + "L": "<Locality (city)>", |
| 69 | + "ST": "<State/Province>" |
| 70 | + }] |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +Replace the placeholder values `<>` with your client certificate's subject values. |
| 75 | + |
| 76 | +### Enable mutual TLS for databases {#enable-mtls-dbs} |
| 77 | + |
| 78 | +Before you can connect to a database using certificate-based authentication, you must enable mutual TLS (mTLS). See [Enable TLS]({{<relref "/operate/rs/security/encryption/tls/enable-tls">}}) for detailed instructions. |
| 79 | + |
| 80 | +### Create certificate auth_method users {#create-cert-users} |
| 81 | + |
| 82 | +When you [create new users]({{<relref "/operate/rs/references/rest-api/requests/users#post-user">}}), include `"auth_method": "certificate"` and `certificate_subject_line` in the request body : |
| 83 | + |
| 84 | +```sh |
| 85 | +POST /v1/users |
| 86 | +{ |
| 87 | + "auth_method": "certificate", |
| 88 | + "certificate_subject_line": "CN=<Common Name>, OU=<Organization Unit>, O=<Organization>, L=<Locality>, ST=<State/Province>, C=<Country>" |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +Replace the placeholder values `<>` with your client certificate's subject values. |
| 93 | + |
| 94 | +## Authenticate REST API requests |
| 95 | + |
| 96 | +To use the REST API with certificate-based authentication, you must provide a client certificate, signed by the trusted CA `mtls_trusted_ca`, and a private key. |
| 97 | + |
| 98 | +The following example uses [cURL](https://curl.se/) to send a [REST API request]({{<relref "/operate/rs/references/rest-api/requests">}}): |
| 99 | + |
| 100 | +```sh |
| 101 | +curl --request <METHOD> --url https://<hostname-or-IP-address>:9443/<API-version>/<API-path> --cert client.pem --key client.key |
| 102 | +``` |
| 103 | + |
| 104 | +## Authenticate database connections |
| 105 | + |
| 106 | +To connect to a database with certificate-based authentication, you must provide a client certificate, signed by the trusted CA `mtls_trusted_ca`, and a private key. |
| 107 | + |
| 108 | +The following example shows how to connect to a Redis database with [`redis-cli`]({{<relref "/operate/rs/references/cli-utilities/redis-cli">}}): |
| 109 | + |
| 110 | +```sh |
| 111 | +redis-cli -h <hostname-or-IP-address> -p <port> --tls --cacert <redis_cert>.pem --cert redis_user.crt --key redis_user_private.key |
| 112 | +``` |
| 113 | + |
| 114 | +## Limitations |
| 115 | + |
| 116 | +- Certificate-based authentication is not implemented for the Cluster Manager UI. |
0 commit comments