Skip to content

Commit 73fc35c

Browse files
Document cert rotation with read-only keystores and truststores for PingData images (#583)
* Document read-only cert rotation process * Formatting for mkdocs * Review edits
1 parent 190cb89 commit 73fc35c

File tree

1 file changed

+92
-10
lines changed

1 file changed

+92
-10
lines changed

docs/reference/usingCertificates.md

+92-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
title: Using Certificates with Images
2+
title: Using Certificates with PingData Images
33
---
4-
# Using Certificates with Images
4+
# Using Certificates with PingData Images
55

66
This page provides details for using certificates with the Ping Identity images. Specifically, it outlines the preferred locations to place the certificate and PIN/key files to provide best security practices and enable use by the underlying Ping Identity product.
77

8-
Currently, certificates can be provided to the PingData products when the containers are started.
8+
Currently, certificates can be provided to the PingData products (PingDirectory, PingDataSync, PingAuthorize, and PingDirectoryProxy) when the containers are started. For non-PingData images, such as PingAccess and PingFederate, the certificates are managed within the product configurations. Those images will not be covered here.
99

1010
## Before you begin
1111

@@ -22,7 +22,7 @@ The following examples explain how to deploy a certificate/PIN combination to an
2222

2323
## PingData Image Certificates
2424

25-
The PingData products (PingDirectory, PingDataSync, PingAuthorize, and PingDirectoryProxy) use a file location to determine certificates/PIN files:
25+
The PingData products use a file location to determine certificates/PIN files:
2626

2727
* It is best practice to use a non-persistent location, such as /run/secrets, to store these files.
2828
* If no certificate is provided, the container/product will generate a self-signed certificate.
@@ -47,14 +47,15 @@ The default location for certificates and associated files are listed below, ass
4747
If a value is not provided, the container will look at the list certs found in the `KEYSTORE_FILE` and if one - and only one - certificate is found of type `PrivateKeyEntry`, that alias will be used.
4848

4949
!!! example "Specifying your own location for a certificate"
50-
If you are relying on certificates to be mounted to a different locations than the SECRET_DIR location or a different filename, you can provide your own values for those variables identified above. As an example:
50+
If you are relying on certificates to be mounted to a different location than the SECRET_DIR location or a different filename, you can provide your own values for those variables identified above. As an example:
5151

5252
```properties
53-
KEYSTORE_FILE=/my/path/to/certs/cert-file
54-
KEYSTORE_PIN_FILE=/my/path/to/certs/cert.pin
53+
KEYSTORE_FILE=/my/path/to/keystores/keystore
54+
KEYSTORE_PIN_FILE=/my/path/to/keystores/keystore.pin
5555
KEYSTORE_TYPE=jks
5656
CERTIFICATE_NICKNAME=development-cert
5757
```
58+
5859
## PingData image certificate rotation
5960
The certificate rotation process for PingData products varies depending on which product is being configured and whether that product is in a topology. For products that are not in a topology, certificates can be rotated by simply updating the environment variables. For products in a topology, certificate rotation must be done via a command-line call with the servers in the topology online.
6061

@@ -64,14 +65,17 @@ The process described in this section can be used for PingAuthorize, PingDirecto
6465
!!! warning
6566
If PingDirectory or PingDataSync is deployed with multiple servers, use the process described in the next section.
6667

67-
As mentioned above, for the PingData products there are variables defining the server truststore and keystore. To change certificates, you will need to update the contents of the truststore or keystore in your server profile or secret store. After you update the contents, restart the container. The changes will be picked up automatically when the server restarts. If you have multiple certificates in the keystore, you can use the above-mentioned CERTIFICATE_NICKNAME variable to specify the certificate. The container will pick up that certificate from those stored in the keystore. For updating the product to use the new certificates, perform a rolling update. This action ensures that other servers will remain available as each pod is cycled.
68+
As mentioned above, for the PingData products there are variables defining the server truststore and keystore. To change certificates, you will need to update the contents of the truststore or keystore in your external storage (Vault etc.). After you update the contents, restart the container. The changes will be picked up automatically when the server restarts. If you have multiple certificates in the keystore, you can use the above-mentioned CERTIFICATE_NICKNAME variable to specify the certificate. The container will pick up that certificate from those stored in the keystore. For updating the product to use the new certificates, perform a rolling update. This action ensures that other servers will remain available as each pod is cycled.
6869

6970
!!! note "Rolling Update"
7071
Verify that remaining pods in the cluster have sufficient capacity to handle the increased load during the rolling update.
7172

7273
### Rotating the listener certificate with the replace-certificate command-line tool
7374
If multiple PingDataSync or PingDirectory servers are running in a topology, then the servers must be online when updating the listener certificate. Updates to certificates with one or more servers offline (such as rolling updates) can lead to connection issues with the other members of the topology when those servers come back online. Use the PingData `replace-certificate` command-line tool to update certificates with the server online.
7475

76+
!!! warning
77+
If your keystore and truststore files are on a read-only filesystem, use the process described in the next section.
78+
7579
Shell into the running instance that needs to be updated, and ensure the keystore containing the needed certificate is mounted on the container. Then, run `replace-certificate`. Replace the `--key-manager-provider` and `--trust-manager-provider` values if necessary when using a non-JKS keystore, as well as the `--source-certificate-alias` value if necessary.
7680

7781
```
@@ -95,6 +99,84 @@ To update certificates for the other servers in the topology, follow this same p
9599

96100
Once this is done, the running pods have been updated. To ensure a restart does not undo these changes, verify that your server profile and orchestration environment variables are updated to point to the new certificates. For example, if you have modified your server configuration to point to `/run/secrets/newkeystore`, then you must update your KEYSTORE_FILE environment variable to point to that new keystore *after* you have completed the `replace-certificate` process on each server.
97101

98-
## Non-PingData image certificates
102+
### Rotating the listener certificate when your keystore and truststore are on a read-only filesystem
103+
Typically, the `replace-certificate` tool will edit your keystore and truststore when rotating your listener certificate. Because of this, the above method will not work when the keystore and truststore are read-only. In this case, use one of the two following processes to rotate your listener certificates.
104+
105+
#### Rotating certificates when they are all signed by the same issuer certificate
106+
If all your listener certs will be signed by the same certificate authority, you can add this CA to your server instance listeners to make rotation easier, as the servers will automatically trust certificates signed by the CA.
107+
108+
##### Add the issuer certificate to the server instance listeners in the topology
109+
110+
- Copy a PEM file of the your issuer certificate onto your pods. For this example the path will be `/opt/out/instance/config/ca.crt`.
111+
- On each server, use `replace-certificate` to add the issuer certificate to the server instance listener for that server. This will make the servers trust each other provided they are using a cert signed by this issuer. *Note* that this must be done with all servers online, so that the change gets replicated to the other servers.
112+
113+
```
114+
replace-certificate add-topology-registry-listener-certificate \
115+
--certificate-file /opt/out/instance/config/ca.crt
116+
```
117+
118+
##### Point the server's key manager provider at your new certificate
119+
120+
- Ensure your new certificate has been added to your keystore in whatever external storage method you are using (Vault, etc.), and note the alias you have given the new cert. For this example the alias will be `newcert`.
121+
- Set `CERTIFICATE_NICKNAME=newcert` and perform a rolling update. `manage-profile replace-profile` will run and point your connection handlers to `newcert`, while the servers will continue to trust each other since that cert was signed by the trusted CA you added in the previous step.
122+
123+
##### Removing the old certs
124+
125+
- If desired, you can now remove unused certs from the server instance listeners in the topology registry. You can also remove the old certs from your keystores in your external storage. To remove the old certs from the topology registry, use `replace-certificate`, running the following command on each server in the topology. *Note* that again this must be done with all servers online, so that the config change gets mirrored across the topology.
126+
```
127+
replace-certificate purge-retired-listener-certificates
128+
```
129+
130+
- It is also possible to purge the retired certificates from a single server rather than running a command on each pod, but it requires some configuration changes since it relies on an extended operation and a specific topology admin permission, so it will likely be easier to simply run the previous command on each server. Using dsconfig, the necessary changes would be:
131+
132+
```
133+
dsconfig create-extended-operation-handler \
134+
--handler-name "Replace Certificate Extended Operation Handler" \
135+
--type replace-certificate \
136+
--set enabled:true \
137+
--set allow-remotely-provided-certificates:true
138+
dsconfig set-topology-admin-user-prop \
139+
--user-name admin \
140+
--add privilege:permit-replace-certificate-request
141+
```
142+
143+
- After these changes are in place on the other servers, the following command can be used to purge retired listener certificates from remote instances:
144+
145+
```
146+
replace-certificate purge-remote-retired-listener-certificates
147+
```
148+
149+
#### Rotating certificates without the assumption that they are all signed by the same issuer certificate
150+
151+
##### Add the new cert to the server instance listeners in the topology
152+
153+
- Add the new desired certificate to your keystore and truststore, in whatever external storage method you are using. Note that you are just adding the new cert, not removing the old one yet. Note the alias that you have given the new cert in the keystore. In these examples the new cert's alias will be `newcert` and the previous one `server-cert`.
154+
- Ensure the pods have the updated keystore and truststore on the filesystem, via a rolling update. At this point the keystores and truststores will have both the old cert and the new cert, but the new one is not yet being used.
155+
- On each server, export the PEM file of the new certificate to a writable location, using the `manage-certificates` tool. This action is necessary because the subsequent command can only use a PEM file, it can’t read from a keystore directly.
156+
157+
```
158+
manage-certificates export-certificate \
159+
--keystore /run/secrets/keystore \
160+
--keystore-password-file /run/secrets/keystore.pin \
161+
--alias newcert \
162+
--output-file /opt/out/instance/config/newcert.crt \
163+
--output-format PEM
164+
```
165+
166+
- On each server, use `replace-certificate` to add the exported certificate PEM file to the server instance listener in the topology. *Note* that this step must be done with all servers online, so that the config change is mirrored to the other servers in the topology.
167+
168+
```
169+
replace-certificate add-topology-registry-listener-certificate \
170+
--certificate-file /opt/out/instance/config/newcert.crt
171+
```
172+
173+
- Now the server will have both the previous cert and the new cert in its server instance listener.
174+
175+
##### Point the server’s key manager provider at the new cert
176+
177+
- There are two ways to do this - first is to change the `CERTIFICATE_NICKNAME` environment variable to point to your new certificate's alias, and then just restart your pods, allowing `manage-profile replace-profile` to apply the change on startup.
178+
- The second is to edit your keystore and truststore and rename your new cert to the same alias as the previous one (in the case of this document, renaming `newcert` to `server-cert` - the previous cert will have to be either renamed or removed from the keystores). This way, the key manager provider for the server will load in the new cert. Then you can restart the pods and the new cert will be loaded on server startup.
179+
180+
##### Removing the old certs
99181

100-
For non-PingData images, such as PingAccess and PingFederate, the certificates are managed within the product configurations.
182+
- Refer to the removal step in the previous section.

0 commit comments

Comments
 (0)