Installing SSL Certificate
SSL Certificate Requirements
Polarity-Clients require the Polarity-Server to use a valid SSL certificate. This certificate must be trusted by the workstation running Polarity Client or Polarity Web. There are several options to meet this requirement including:
Buy a SSL certificate.
Generate a server certificate from an internal Certificate Authority trusted by Polarity Client workstations.
Use a self-signed certificate and add it to the trusted store on all Polarity Client workstations
Options 1 and 2 are the preferred methods for all Polarity deployments in enterprise environments. If you elect to generate a self-signed SSL certificate, please refer to the SSL Certificate Generation section.
Certificate Format Requirements
Before installing your certificates please ensure the certificates are in the right format. The SSL certificate and private key should be encoded in the PEM format using the PKCS8 container. The public and private keys should be two separate files (typically a public .crt
and a private .key
file). The .crt
file might also be generated as a .pem
file.
Private Key Format
The private key should not have a passphrase on it. If your private key has a passphrase on it you can generate a copy of the key without a passphrase by running the following command on the Polarity Server:
The original.key
should be the key with the passphrase and new.key
will be same key with the passphrase removed. When running the above command you will be prompted for the passphrase.
You can check to see if you private key is in the right format by viewing the content of the key. The file content should look like this:
Public Certificate
The certificate file (.crt
) should include all the certificates in your chain starting with the most specific. If you have multiple .crt
files they will need to be combined into a single certificate. You can easily do this with the cat
command like this:
The above command will add the contents of three certificates cert1.crt
, cert2.crt
, cert3.crt
into the file server.crt
. In this example, cert1
should be the most specific certificate. If you have more certificates simply add the additional file names to the cat
command.
You can check the format of your public key by viewing the content of the file which should look like this:
SSL Certificate Installation
The SSL certificate and key should be copied to Polarity Server and placed in the following locations:
Filename
Location
server.crt
/etc/pki/tls/certs/server.crt
server.key
/etc/pki/tls/private/server.key
The SSL certificate should be in PEM format.
Permissions, including SELinux type context, should be applied to the SSL certificate and key as the root user using the following commands:
If you see the following errors when trying to apply the contexts to the server.crt
file and server.key
file:
Then you should use the following commands instead:
After the certificate and private key are installed, restart NGINX to ensure the certificate is accepted:
If NGINX fails to restart, please verify the permissions and SELinux context for the SSL certificate and key. SELinux errors usually manifest themselves as permission denied errors when NGINX attempts to access the SSL certificate or key files and can be discovered by reviewing the nginx error log or audit log:
Once NGINX is successfully restarted, restart the Polarity Server service to ensure the certificate is accepted:
Self-Signed SSL Certificate Generation
If you elect to generate a self-signed SSL certificate, please generate an SSL certificate that supports SHA256 with a minimum RSA size of 2048.
To make it easier to generate a self-signed certificate Polarity provides a utility script called create-self-signed-cert.sh
. Simply run the script as root and follow the instructions. The script will generate a valid self-signed certificate and install the certificate onto your server.
Converting Between Formats
Converting PKCS1 to PKCS8
If your private key is in PKCS1 format, when you output the file you will see the following:
The header will say BEGIN RSA PRIVATE KEY
instead of just BEGIN PRIVATE KEY
. If this is the case, you can convert your private key from PKCS1 format to PKCS8 format using the following openssl command.
Replace <private_pkcs1.pem>
with the name of your PKCS1 private key. The command will output the equivalent PKCS8 private key and name it server.key
which is the naming format expected by Polarity Server.
If your public key is in PKCS1 format, when you output the file you will see the following:
To convert the public key from PKCS1 to PKCS8 you can use the following command:
Replace <public_pkcs1.pem>
with the name of your PKCS1 public key. The command will output the equivalent PKCS8 public key and name it server.crt
which is the naming format expected by Polarity Server.
DER encoding
DER is a binary encoding. If you open your certificate and are unable to read the content of the certificate it could be DER encoded. To confirm that the certificate is DER encoded run the command:
Replace <cert.cer>
with the certificate you want to test. If the certificate is in DER format you will see the certificate content output. If the certificate is not in DER format you will get the error message unable to load certificate
.
If the certificate is DER encoded you can convert it to PEM encoding using the command:
Replace <cert.cer>
with the name of your certificate. The command will output the equivalent PEM encoded public key and name it server.crt
which is the naming format expected by Polarity Server.
Troubleshooting
Checking Certificate Subject
It is important that your certificate subject matches the FQDN of your Polarity Server. To check that these match you can use the following command:
To decode and view the entire certificate:
Private key has a passphrase
If your private key has a passphrase (i.e., is encrypted), you will need to remove the passphrase before the key can be used by the server. To do this you can run the following command.
The comman will prompt you for the passphrase and will then output a copy of the key called server.key
without the passphrase.
Private Key and Public Cert Mismatch
If you see the following error when attempting to start nginx after replacing your public and private key it means the private key and certificate do not match.
You can check to make sure your private key and certificate match by ensuring the MD5s from the following commands match:
File Permission Error on Certificate
If the certificate has incorrect permissions and is not readable by the Polarity user, you may see the following errors in the Polarity Server logs.
In this scenario, ensure the server.crt
file is owned by the polarityd
user.
Last updated