Questo contenuto non è disponibile nella lingua selezionata.
Chapter 17. Recovering from expired system certificates
If Identity Management (IdM) certificates expire, core services such as the Web UI, LDAP, and certificate issuance fail. Commands like ipa-certupdate
and ipa-cacert-manage
do not work because the system cannot establish secure connections. The following sections provide procedures for several critical failure scenarios.
Before making any changes, create a full backup of your IdM servers. At a minimum, create a file-level backup of critical data on each server:
# tar czvf /root/pki-backup_$(hostname -f)_$(date +%F).tar.gz /etc/dirsrv/slapd-* /etc/pki/pki-tomcat/ /var/lib/ipa/ /var/kerberos/krb5kdc/
Do not proceed without a reliable backup.
Use the ipa-cert-fix
command with extreme caution. ipa-cert-fix
is a powerful but intrusive tool designed for a specific failure scenario: expired service certificates on the renewal server.
-
Do not run
ipa-cert-fix
if the CA certificate itself is expired. -
Do not run
ipa-cert-fix
on a replica server, except if the renewal server is in an unrecoverable state. Open a support ticket if you find yourself in this situation. -
Do not run
ipa-cert-fix
as a general troubleshooting tool.
Misusing this tool can make the situation worse.
17.1. Recovering from expired service certificates on a replica Copia collegamentoCollegamento copiato negli appunti!
In this failure scenario, the renewal server is healthy, but one or more replicas have failed to renew their certificates and are now offline. The goal is to manually synchronize or re-issue the necessary certificates from the server to restore the replica.
This procedure covers four critical certificates: the RA Agent
certificate, the Subsystem
certificate, the Directory Server (LDAP)
certificate, and the PKI Tomcat (Web Server)
certificate.
If you are unsure which server is the renewal server, run the following command on any IdM server. The command output is the distinguished name (DN) of the CA renewal server:
ldapsearch -Y GSSAPI -b cn=masters,cn=ipa,cn=etc,dc=example,dc=com ipaConfigString=caRenewalMaster dn
# ldapsearch -Y GSSAPI -b cn=masters,cn=ipa,cn=etc,dc=example,dc=com ipaConfigString=caRenewalMaster dn
If Kerberos is unavailable, use the following command with the Directory Manager password:
ldapsearch -x -D 'cn=Directory Manager' -W -b cn=masters,cn=ipa,cn=etc,dc=example,dc=com ipaConfigString=caRenewalMaster dn
# ldapsearch -x -D 'cn=Directory Manager' -W -b cn=masters,cn=ipa,cn=etc,dc=example,dc=com ipaConfigString=caRenewalMaster dn
Procedure
Verify that the IdM services are running:
ipactl status
# ipactl status
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional. If any of the services are not running, force them to start:
ipactl start -f
# ipactl start -f
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
-f
or--force
flag bypasses some of the startup checks, which is necessary when services cannot communicate due to expired certificates.Compare RA Agent and Subsystem certificates between the renewal server and the failing replica.
On both the healthy renewal server and the failing replica, retrieve the serial numbers of the RA agent and subsystem certificates, and verify that they are identical.
RA Agent certificate and its corresponding LDAP entry. The serial number is the second value in the semicolon-separated
description
attribute string, for example2;SERIAL;…
:openssl x509 -in /var/lib/ipa/ra-agent.pem -noout -serial ldapsearch -D "cn=directory manager" -W -b "uid=ipara,ou=people,o=ipaca" description
# openssl x509 -in /var/lib/ipa/ra-agent.pem -noout -serial # ldapsearch -D "cn=directory manager" -W -b "uid=ipara,ou=people,o=ipaca" description
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Subsystem certificate and its corresponding LDAP entry. The serial number is the second value in the semicolon-separated
description
attribute string, for example2;SERIAL;…
:certutil -L -d /etc/pki/pki-tomcat/alias/ -n 'subsystemCert cert-pki-ca' | grep "Serial Number" ldapsearch -D "cn=directory manager" -W -b "uid=pkidbuser,ou=People,o=ipaca" description
# certutil -L -d /etc/pki/pki-tomcat/alias/ -n 'subsystemCert cert-pki-ca' | grep "Serial Number" # ldapsearch -D "cn=directory manager" -W -b "uid=pkidbuser,ou=People,o=ipaca" description
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the serial numbers on the replica do not match those on the CA renewal server, proceed with the next steps to synchronize them.
Manually copy the healthy certificates to the replica. From the renewal server, copy the
ra-agent.pem
and the subsystem certificate to the failing replica.Copy the RA agent certificate file:
scp /var/lib/ipa/ra-agent.pem root@failed-replica.idm.example.com:/tmp/
# scp /var/lib/ipa/ra-agent.pem root@failed-replica.idm.example.com:/tmp/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Export the subsystem certificate:
certutil -L -d /etc/pki/pki-tomcat/alias -n 'subsystemCert cert-pki-ca' -a > /tmp/subsystem.pem
# certutil -L -d /etc/pki/pki-tomcat/alias -n 'subsystemCert cert-pki-ca' -a > /tmp/subsystem.pem
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the subsystem certificate:
scp /tmp/subsystem.pem root@failed-replica.idm.example.com:/tmp/
# scp /tmp/subsystem.pem root@failed-replica.idm.example.com:/tmp/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
On the failing replica, replace the expired RA agent certificate.
Copy the healthy certificate into place:
cp /tmp/ra-agent.pem /var/lib/ipa/ra-agent.pem
# cp /tmp/ra-agent.pem /var/lib/ipa/ra-agent.pem
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the corresponding entry in LDAP to ensure it contains the correct certificate blob and serial number. This step requires the Directory Manager password.
Prepare the new RA agent certificate for LDAP by converting it to a single-line blob and storing it in a variable:
RA_CERT_BLOB=$(sed -rn '/^-----BEGIN CERTIFICATE-----$/{:1;n;/^-----END CERTIFICATE-----$/b2;H;b1};:2;${x;s/\s//g;p}' /tmp/ra-agent.pem)
# RA_CERT_BLOB=$(sed -rn '/^-----BEGIN CERTIFICATE-----$/{:1;n;/^-----END CERTIFICATE-----$/b2;H;b1};:2;${x;s/\s//g;p}' /tmp/ra-agent.pem)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Extract the serial number from the new certificate and store it in a variable:
RA_CERT_SERIAL=$(openssl x509 -in /tmp/ra-agent.pem -noout -serial | cut -d'=' -f2)
# RA_CERT_SERIAL=$(openssl x509 -in /tmp/ra-agent.pem -noout -serial | cut -d'=' -f2)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure the IdM services are running before attempting to modify the LDAP database:
ipactl start -f
# ipactl start -f
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the LDAP entry for the RA agent with the new certificate blob and serial number. You will be prompted for the Directory Manager password:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
IDM.EXAMPLE.COM
with your IdM realm or use your custom certificate subject base.
On the failing replica, replace the expired subsystem certificate.
Import the healthy certificate into the NSS database. This requires the NSS database password, which can be found in
/etc/pki/pki-tomcat/password.conf
.Set a variable for the location of the NSS database password file for easier use in the following commands:
PWDFILE=/etc/pki/pki-tomcat/alias/pwdfile.txt
# PWDFILE=/etc/pki/pki-tomcat/alias/pwdfile.txt
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the old, expired subsystem certificate from the NSS database:
certutil -D -d /etc/pki/pki-tomcat/alias -n 'subsystemCert cert-pki-ca' -f $PWDFILE
# certutil -D -d /etc/pki/pki-tomcat/alias -n 'subsystemCert cert-pki-ca' -f $PWDFILE
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the new, healthy subsystem certificate from the
/tmp/subsystem.pem
file to the NSS database:certutil -A -d /etc/pki/pki-tomcat/alias -n 'subsystemCert cert-pki-ca' -t ",," -i /tmp/subsystem.pem -f $PWDFILE
# certutil -A -d /etc/pki/pki-tomcat/alias -n 'subsystemCert cert-pki-ca' -t ",," -i /tmp/subsystem.pem -f $PWDFILE
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Update the corresponding entry in LDAP, similar to the RA agent step:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
IDM.EXAMPLE.COM
with your IdM realm or use your custom certificate subject base.
Manually issue a temporary certificate for the replica’s LDAP service.
On the failing replica, generate a Certificate Signing Request (CSR) from the existing key in the Directory Server’s NSS database:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe command above creates
/tmp/ldap.csr
. Some versions ofcertutil
may add extra text to the file. Ensure the file contains only the-----BEGIN NEW CERTIFICATE REQUEST-----
block and nothing else.If the certificate is signed by the IdM CA:
On the failing replica, copy the CSR to the renewal server:
scp /tmp/ldap.csr root@renewal-master.idm.example.com:/tmp/
# scp /tmp/ldap.csr root@renewal-master.idm.example.com:/tmp/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow On the renewal server, sign the CSR. Use the
ldap/
principal to ensure the certificate is valid for GSSAPI binds:ipa cert-request /tmp/ldap.csr --principal="ldap/$(hostname -f)" --certificate-out=/tmp/ldap.pem
# ipa cert-request /tmp/ldap.csr --principal="ldap/$(hostname -f)" --certificate-out=/tmp/ldap.pem
Copy to Clipboard Copied! Toggle word wrap Toggle overflow On the renewal server, copy the new certificate back to the replica:
scp /tmp/ldap.pem root@failed-replica.idm.example.com:/tmp/
# scp /tmp/ldap.pem root@failed-replica.idm.example.com:/tmp/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow On the failing replica, import the new certificate into the Directory Server’s NSS database:
certutil -D -d "/etc/dirsrv/${DS_INSTANCE}" -n ${LDAP_CERT_NICKNAME} -f "${PWDFILE}" certutil -A -d "/etc/dirsrv/${DS_INSTANCE}" -n ${LDAP_CERT_NICKNAME} -t ",," -i /tmp/ldap.pem -f "${PWDFILE}"
# certutil -D -d "/etc/dirsrv/${DS_INSTANCE}" -n ${LDAP_CERT_NICKNAME} -f "${PWDFILE}" # certutil -A -d "/etc/dirsrv/${DS_INSTANCE}" -n ${LDAP_CERT_NICKNAME} -t ",," -i /tmp/ldap.pem -f "${PWDFILE}"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
If the certificate is signed by an external CA:
-
Take the
/tmp/ldap.csr
file and submit it to your external Certificate Authority for signing. -
Once you receive the new certificate file (for example,
new_ldap_cert.pem
), copy it securely to the/tmp/
directory on the failing replica and rename it toldap.pem
. On the failing replica, import the new certificate into the Directory Server’s NSS database:
certutil -D -d "/etc/dirsrv/${DS_INSTANCE}" -n ${ LDAP_CERT_NICKNAME} -f "${PWDFILE}" certutil -A -d "/etc/dirsrv/${DS_INSTANCE}" -n ${ LDAP_CERT_NICKNAME} -t ",," -i /tmp/ldap.pem -f "${PWDFILE}"
# certutil -D -d "/etc/dirsrv/${DS_INSTANCE}" -n ${ LDAP_CERT_NICKNAME} -f "${PWDFILE}" # certutil -A -d "/etc/dirsrv/${DS_INSTANCE}" -n ${ LDAP_CERT_NICKNAME} -t ",," -i /tmp/ldap.pem -f "${PWDFILE}"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Take the
Manually issue a temporary certificate for the replica’s PKI Tomcat service.
On the affected replica, generate a CSR using the existing key stored in the PKI Tomcat NSS database:
HOSTNAME=$(hostname -f) PWDFILE="/etc/pki/pki-tomcat/alias/pwdfile.txt" certutil -R -d /etc/pki/pki-tomcat/alias -k 'Server-Cert cert-pki-ca' -n 'Server-Cert cert-pki-ca' -s "CN=${HOSTNAME},O=IDM.EXAMPLE.COM" -a -f "${PWDFILE}" -o /tmp/server-cert.csr
# HOSTNAME=$(hostname -f) # PWDFILE="/etc/pki/pki-tomcat/alias/pwdfile.txt" # certutil -R -d /etc/pki/pki-tomcat/alias -k 'Server-Cert cert-pki-ca' -n 'Server-Cert cert-pki-ca' -s "CN=${HOSTNAME},O=IDM.EXAMPLE.COM" -a -f "${PWDFILE}" -o /tmp/server-cert.csr
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
IDM.EXAMPLE.COM
with your IdM realm or use your custom certificate subject base.On the failing replica, copy the CSR to the renewal server:
scp /tmp/server-cert.csr root@renewal-master.idm.example.com:/tmp/
# scp /tmp/server-cert.csr root@renewal-master.idm.example.com:/tmp/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow On the renewal server, sign the CSR. Use the
host/
principal for the web server certificate:ipa cert-request /tmp/server-cert.csr --principal="host/$(hostname -f)" --certificate-out=/tmp/server-cert.pem
# ipa cert-request /tmp/server-cert.csr --principal="host/$(hostname -f)" --certificate-out=/tmp/server-cert.pem
Copy to Clipboard Copied! Toggle word wrap Toggle overflow On the renewal server, copy the new certificate back to the replica:
scp /tmp/server-cert.pem root@failed-replica.idm.example.com:/tmp/
# scp /tmp/server-cert.pem root@failed-replica.idm.example.com:/tmp/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow On the failing replica, import the new certificate into the PKI Tomcat NSS database:
certutil -D -d /etc/pki/pki-tomcat/alias -n 'Server-Cert cert-pki-ca' -f "${PWDFILE}" certutil -A -d /etc/pki/pki-tomcat/alias -n 'Server-Cert cert-pki-ca' -t ",," -i /tmp/server-cert.pem -f "${PWDFILE}"
# certutil -D -d /etc/pki/pki-tomcat/alias -n 'Server-Cert cert-pki-ca' -f "${PWDFILE}" # certutil -A -d /etc/pki/pki-tomcat/alias -n 'Server-Cert cert-pki-ca' -t ",," -i /tmp/server-cert.pem -f "${PWDFILE}"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Restart services and renew remaining certificates.
Restart the IdM services on the replica to use the new certificates:
ipactl restart
# ipactl restart
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
certmonger
service to apply the manual changes. Once restarted, it should begin attempting to renew any remaining certificates:systemctl restart certmonger
# systemctl restart certmonger
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
You can watch the renewal process by periodically running
getcert list | grep -E "Request ID|status|expires"
. Once all certificates are in theMONITORING
state, the process is complete. The
certmonger
service should now be able to communicate with the CA. If one or more certificates remain unrenewed after a few minutes, consider renewing them manually:getcert list getcert resubmit -i <REQUEST_ID>
# getcert list # getcert resubmit -i <REQUEST_ID>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
17.2. Recovering from expired service certificates on the renewal server Copia collegamentoCollegamento copiato negli appunti!
In this scenario, the IdM CA certificate is still valid, but other service certificates (LDAP, HTTPD) have expired on the renewal server itself. The ipa-cert-fix
utility is specifically designed to address this type of issue.
Procedure
Stop IdM services on the renewal server:
ipactl stop
# ipactl stop
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run
ipa-cert-fix
to:- Inspect tracked certificates.
- Resets the certificates' expiration dates in LDAP.
Allow
certmonger
to issue new certificates.Type
yes
to continue when prompted:ipa-cert-fix
# ipa-cert-fix
Copy to Clipboard Copied! Toggle word wrap Toggle overflow WarningDo not run the
ipa-cert-fix
command if your CA is expired. In that case, skip this step.
Run
ipa-certupdate
to propagate the newly fixed and issued certificates to all system services:ipa-certupdate
# ipa-certupdate
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart IdM and verify:
ipactl restart
# ipactl restart
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
17.3. Recovering from an expired IdM CA certificate Copia collegamentoCollegamento copiato negli appunti!
This is the most critical failure. If the IdM CA certificate itself expires, no certificates can be validated or issued. The recovery process involves renewing the CA certificate as self-signed to restore system functionality, and then optionally re-signing it with an external CA if that was your original configuration.
Procedure
On the renewal server, renew the CA certificate as self-signed. This command uses the existing private key to generate a new CA certificate with a renewed validity period:
ipa-cacert-manage renew --self-signed
# ipa-cacert-manage renew --self-signed
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If your certificate is close to its expiry date and renewing it did not push the expiry date forward, see the When IPA’s CA certificate is close to expiry date, renewing it doesn’t push forward the expiry date solution.
Fix expired service certificates on the renewal server.
Stop the IdM services:
ipactl stop
# ipactl stop
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the
ipa-cert-fix
command to reset the expiration date of expired service certificates in the IdM database:ipa-cert-fix
# ipa-cert-fix
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Issue new certificates and apply them to the IdM services:
ipa-certupdate
# ipa-certupdate
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the IdM services to complete the renewal:
ipactl start
# ipactl start
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
If your original setup used an externally-signed CA, you must now get the new CA certificate re-signed by your external authority. If you use a self-signed CA, skip this step.
Generate a certificate-signing request (CSR) for the newly renewed CA:
ipa-cacert-manage renew --external-ca
# ipa-cacert-manage renew --external-ca
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This creates a CSR file at
/var/lib/ipa/ca.csr
.- Submit the CSR file to your external CA and receive the newly signed certificate and the external CA’s chain of trust.
Install the newly signed certificate back into IdM:
ipa-cacert-manage renew --external-cert-file /path/to/new-ca.pem --external-cert-file /path/to/external-chain.pem
# ipa-cacert-manage renew --external-cert-file /path/to/new-ca.pem --external-cert-file /path/to/external-chain.pem
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Propagate the new CA certificate to all IdM servers and clients. Run the
ipa-certupdate
on the renewal server first, then on all other replicas, and finally on all clients:ipa-certupdate
# ipa-certupdate
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This step is critical to ensure all systems in the topology trust the new CA certificate.