Managing SSL certificates v9
PEM uses self-signed SSL certificates:
- To secure requests to the web server (Apache httpd), which provides the user interface and REST API.
- To secure and authenticate the PEM agent connections to the PEM backend database.
Web-server certificates
PEM uses self-signed SSL certificates for the Apache httpd server. The self-signed SSL certificate and key files for the Apache httpd server are generated during PEM installation.
To use your own SSL certificate for PEM, update the Apache HTTP configuration file edb-ssl-pem.conf
.
Update these two SSL directives in the PEM VirtualHost section:
SSLCertificateFile
is your certificate file, for example,your_domain_name.crt
.SSLCertificateKeyFile
is the.key
file generated when you created the certificate signing request (CSR), for example,your_private.key
.
For example, make the following updates:
To increase security, you can replace the httpd self-signed SSL certificates with trusted CA signed certificates in PEM. For more information, see Replacing httpd self-signed SSL certificates.
PEM backend database server and agent connection certificates
By default, PEM implements secured SSL/TLS connections between PEM agents and the backend database. It also acts as its own certificate authority (CA) to generate certificates and keys for the PEM server and agent. The self-signed SSL certificates and keys for the PEM server and agent are generated during PEM installation. These certificates and keys encrypt the connection from agent to server. In addition, PEM agents are authenticated using their certificate rather than a password.
You can replace the PEM self-signed SSL certificates and keys with the trusted CA certificates and keys. For more information, see Trusted CA certificates and keys.
How PEM self-signed SSL certificates work
The PEM server configuration script generates self-signed SSL certificate and key files for the PEM backend database server. The backend database server uses these certificates and keys to authenticate and encrypt the agent connections. Each certificate has an expiry date. Regenerate the certificates when they near expiration. For more information, see Regenerating server self-signed SSL certificates.
The PEM agent connects to the PEM backend database server using the libpq interface, acting as a client of the backend database server. The agent self-signed SSL certificates and keys get generated during agent registration. PEM agent establishes the connection with the PEM backend database server using the self-signed SSL certificate and key files.
Each agent has a unique identifier, and the agent certificates and keys have the corresponding identifier. Each certificate has an expiry date. Regenerate the certificates when they near expiration. For more information, see Regenerating agent self-signed SSL certificates.
If required, you can use the same certificate for all agents rather than one certificate per agent. For more information, see Generate common agent certificate and key pair.
For more information on using the SSL certificates to connect in Postgres, see Securing TCP/IP connections with SSL.
Certificate and key files generation
The PEM server generates the certificates and key files in the data directory of the backend database server:
ca_certificate.crt
ca_key.key
root.crt
root.crl
server.crt
server.key
The ca_certificate.crt
and ca_key.key
files are used during the agent registration process to generate the agent's SSL certificates and key files.
The root.crt
file is a copy of the ca_certificate.crt
file. You use the root certificate for the backend database server by setting the ssl_ca_file
parameter as root.crt
in the postgresql.conf
file.
The root.crl
has the certificate revocation list (CRL) of digital certificates revoked by the issuing CA before their actual or assigned expiration date.
The server.crt
file is the signed certificate for the PEM server, and the server.key
file is the private key to the certificate. The PEM agent certificates are generated using these server certificate and key files.
PEM self-signed SSL certificate renewal
The PEM agent installed with the PEM server monitors the expiration date of the ca_certificate.crt
file. When the certificate is about to expire, PEM:
- Makes a backup of the existing certificate files
- Creates new certificate files and appends the new CA certificate file to the
root.crt
file on the PEM server - Creates a job to renew the certificate file of any active agents
- Restarts the PEM server
Generate a common agent certificate and key pair
By creating and using a single Postgres user for all PEM agents rather than one user per agent (the default), you can use the same certificate for all agents.
Create a user, generate an agent certificate and key pair, and use them for all PEM agents.
Create one common agent user in the PEM backend database. Grant the
pem_agent
role to the user.Generate an agent key: