9.3. Managing the NSS Database Used by Directory Server
dscreate
utility automatically created this database in the /etc/dirsrv/slapd-instance_name/
directory and protected it with a strong password. The utility stored the password in the /etc/dirsrv/slapd-instance_name/pwdfile.txt
file. Note that Directory Server does not use this file. The dscreate
utility only created this file to provide the password to the administrator. For details about changing the password, see Section 9.3.10, “Changing the Password of the NSS Database”.
9.3.1. Creating a Certificate Signing Request
Note
certutil
utility.
9.3.1.1. Creating a Certificate Signing Request Using the Command Line
dsctl tls generate-server-cert-csr
command:
# dsctl instance_name tls generate-server-cert-csr -s "certificate_subject"
dsctl tls generate-server-cert-csr
command stores the CSR in the /etc/dirsrv/slapd-instance_name/Server-Cert.csr
file and the private key in the Directory Server's network security services (NSS) database.
Example 9.1. Creating a Private Key and CSR for a Single Host Name
server.example.com
host:
# dsctl instance_name tls generate-server-cert-csr -s "CN=server.example.com,O=example_organization,OU=IT,ST=North Carolina,C=US"
-s
parameter must be a valid subject name according to RFC 1485. The CN
field is required, and you must set it to the Fully-qualified Domain Name (FQDN) of the server. The other fields are optional.
Example 9.2. Creating a Private Key and CSR for a Multi-homed Host
server.example.com
and server.example.net
host names:
# dsctl instance_name tls generate-server-cert-csr -s "CN=server.example.com,O=example_organization,OU=IT,ST=North Carolina,C=US" server.example.com server.example.net
DNS:server.example.com, DNS:server.example.net
entries to the CSR. The string specified in the -s
parameter must be a valid subject name according to RFC 1485. The CN
field is required, and you must set it to one of the FQDNs of the server. The other fields are optional.
9.3.2. Installing a CA Certificate
Web Console Option | dsconf and certutil Option | Description |
---|---|---|
(C) Trusted CA | C,, | The server verifies that certificates, used to establish an encrypted connection to a replication partner, have been issued by a trusted CA. |
(T) Trusted CA Client Auth | T,, | The server trusts this CA certificate for issuing client certificates suitable for TLS EXTERNAL binds. |
certutil
, pass the -T "CT,,"
parameter to the utility.
9.3.2.1. Installing a CA Certificate Using the Command Line
- Import the CA certificate. For example, to import the CA certificate stored in the
/root/ca.crt
file and store it in the database with theExample CA
nick name:# dsconf -D "cn=Directory Manager" ldap://server.example.com security ca-certificate add --file /root/ca.crt --name "Example CA"
- Set the trust options. For example, to set the
CT,,
trust flags:# dsconf -D "cn=Directory Manager" ldap://server.example.com security ca-certificate set-trust-flags "Example CA" --flags "CT,,"
9.3.2.2. Installing a CA Certificate Using the Web Console
- Open the Directory Server user interface in the web console. See Section 1.4, “Logging Into Directory Server Using the Web Console”.
- Select the instance.
- Open the Security entry.menu, and select the
- Open the Certificate Management tab, and select the Trusted Certificate Authorities sub-tab.
- Click.
- Enter the path to the CA certificate file and a nickname for the certificate.
Figure 9.1. Adding a CA Certificate
Note
The CA certificate must be stored locally on the Directory Server host and must be readable by thedirsrv
user. - Click.
- Click Edit Trust Flags.next to the imported CA certificate, and select
- Select (C) - Trusted CA and (T) - Trusted CA Client Auth in the SSL column.
Figure 9.2. Adding Trust Flags of a CA Certificate
9.3.3. Importing a Private Key and Server Certificate
/root/server.crt
and the private key from the /root/server.key
file, enter:
# dsctl instance_name tls import-server-key-cert /root/server.crt /root/server.key
dsctl tls import-server-key-cert
command requires the paths in the following order:
- Path to the server certificate.
- Path to the private key file.
9.3.4. Installing a Server Certificate
9.3.4.1. Installing a Server Certificate Using the Command Line
certutil
utility. For example:
- Install the CA certificate. See Section 9.3.2, “Installing a CA Certificate”.
- Import the server certificate. For example to import the certificate stored in the
/root/instance_name.crt
file, and set it as the primary certificate the instance uses:# dsconf -D "cn=Directory Manager" ldap://server.example.com security certificate add --file /root/instance_name.crt --name "Server-Cert" --primary-cert
9.3.4.2. Installing a Server Certificate Using the Web Console
- Install the CA certificate. See Section 9.3.2, “Installing a CA Certificate”.
- Open the Directory Server user interface in the web console. See Section 1.4, “Logging Into Directory Server Using the Web Console”.
- Select the instance.
- Open the Security entry.menu, and select the
- Open the Certificate Management tab, and select the TLS Certificates sub-tab.
- Click.
- Enter the path to the server certificate file and a nickname for the certificate.
Figure 9.3. Adding a Server Certificate
Note
The server certificate must be stored locally on the Directory Server host and must be readable by thedirsrv
user. - Click.
9.3.5. Generating and Installing a Self-signed Certificate
dscreate
utility, dscreate
automatically created and installed a self-signed certificate. However, if you did not enable TLS during instance creation, you can manually create and install a self-signed certificate.
Note
- Generate a noise file with random data. For example, to generate a file with a size of 4096 bits:
# openssl rand -out /tmp/noise.bin 4096
- Create the self-signed certificate and add it to the NSS database:
# certutil -S -x -d /etc/dirsrv/slapd-instance_name/ -z /tmp/noise.bin \ -n "Server-Cert" -s "CN=$HOSTNAME" -t "CT,C,C" -m $RANDOM \ --keyUsage digitalSignature,nonRepudiation,keyEncipherment,dataEncipherment
Red Hat Enterprise Linux automatically replaces the$HOSTNAME
variable with the Fully Qualified Domain Name (FQDN) and$RANDOM
with a randomly-generated number. For further details about the parameters used in the previous commands, see the certutil(1) man page. - Optionally, verify that the generated certificate is self-signed:
# certutil -L -d /etc/dirsrv/slapd-instance_name/ -n "Server-Cert" | egrep "Issuer|Subject" Issuer: "CN=server.example.com" Subject: "CN=server.example.com"
The output of this command must display the FQDN of the Directory Server host for both the issuer and subject of the certificate.
9.3.6. Renewing a Certificate
9.3.6.1. Renewing a Certificate Using the Command Line
- If you do not use attribute encryption:
- Create a new Certificate Signing Request (CSR) with the same options, such as key size, host name, and subject. For details about creating a CSR, see Section 9.3.1.1, “Creating a Certificate Signing Request Using the Command Line”
- After you received the issued certificate from your CA, install it in the database using the same nickname. See Section 9.3.2.1, “Installing a CA Certificate Using the Command Line”.
- Stop the instance:
# dsctl instance_name stop
- Edit the
/etc/dirsrv/slapd-instance_name/dse.ldif
file and remove the following entries including their attributes:cn=AES,cn=encrypted attribute keys,cn=database_name,cn=ldbm database,cn=plugins,cn=config
cn=3DES,cn=encrypted attribute keys,cn=database_name,cn=ldbm database,cn=plugins,cn=config
Important
Remove the entries for all databases. If any entry that contains thensSymmetricKey
attribute is left in the/etc/dirsrv/slapd-instance_name/dse.ldif
file, Directory Server will fail to start. - Start the instance:
# dsctl instance_name start
Directory Server will automatically use the newer issued certificate. - If you use attribute encryption, see Section 10.5, “Updating the TLS Certificates Used for Attribute Encryption”.
9.3.7. Removing a Certificate
9.3.7.1. Removing a Certificate Using the Command Line
- Optionally, display the certificates in the database:
# dsconf -D "cn=Directory Manager" ldap://server.example.com security certificate list Certificate Name: Server-Cert Subject DN: CN=server.example.com Issuer DN: CN=Example CA Expires: 2022-07-29 11:10:14 Trust Flags: ,,
- Remove the certificate. For example, to remove the certificate with the Server-Cert nickname:
# dsconf -D "cn=Directory Manager" ldap://server.example.com security certificate del Server-Cert
9.3.7.2. Removing a Certificate Using the Web Console
- Open the Directory Server user interface in the web console. See Section 1.4, “Logging Into Directory Server Using the Web Console”.
- Select the instance.
- Open the Security entry.menu, and select the
- Open the Certificate Management tab, and select the TLS Certificates sub-tab.
- Click Delete Certificate.next to the certificate, and select
- Click.
9.3.8. Removing a Private Key
Warning
9.3.8.1. Removing a Private Key Using the Command Line
- Remove all certificates based on the key you want to delete. See Section 9.3.7, “Removing a Certificate”.
- Optionally, display the keys in the database:
# certutil -d /etc/dirsrv/slapd-instance_name/ -K certutil: Checking token "NSS Certificate DB" in slot "NSS User Private Key and Certificate Services" Enter Password or Pin for "NSS Certificate DB": < 0> rsa 7a2fb6c269d83c4036eac7e4edb6aaf2ed08bc4a Server-Cert < 1> rsa 662b826aa3dd4ca7fd7e6883558cf3866c42f4e2 example-cert
- Remove the private key. For example, to remove the private key with the example-cert nickname:
# certutil -d /etc/dirsrv/slapd-instance_name/ -F -n "example-cert"
9.3.9. Changing the CA Trust Options
9.3.9.1. Changing the CA Trust Options Using the Command Line
--flags
parameter to the dsconf security ca-certificate set-trust-flags
command.
example-CA
:
# dsconf -D "cn=Directory Manager" ldap://server.example.com security ca-certificate set-trust-flags "example-CA" --flags "T,,"
--flags trust_options
parameter sets which certificates issued by the CA should be trusted. See Table 9.1, “CA Trust Options”.
9.3.9.2. Changing the CA Trust Options Using the Web Console
- Open the Directory Server user interface in the web console. See Section 1.4, “Logging Into Directory Server Using the Web Console”.
- Select the instance.
- Open the Security entry.menu, and select the
- Open the Certificate Management tab.
- On the Trusted Certificate Authorities sub-tab, click next to the imported CA certificate, and select Edit Trust Flags.
- Select the trust flags. For example:
Figure 9.4. Setting the Trust Flags of a CA Certificate
- Click.
9.3.10. Changing the Password of the NSS Database
Important
9.3.10.1. Changing the Password of the NSS Database Using the Command Line
# certutil -d /etc/dirsrv/slapd-instance_name -W Enter Password or Pin for "NSS Certificate DB": Enter a password which will be used to encrypt your keys. The password should be at least 8 characters long, and should contain at least one non-alphabetic character. Enter new password: Re-enter password: Password changed successfully.