Configure the Server SSL Certificates
  • 23 Dec 2024
  • 7 Minutes to read
  • Dark
    Light

Configure the Server SSL Certificates

  • Dark
    Light

Article summary

Polarity Server Certificates

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:

  1. Buy a commercial SSL certificate
  2. Generate a server certificate from an internal Certificate Authority (CA) 
  3. Use a self-signed certificate and add it to the trusted store on all Polarity Client workstations
Not sure?
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 they are in the correct 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 may also be generated as a .pem file.

Private Key Requirements

The private key should not have a passphrase on it.  If your private key has a passphrase, you can generate a copy of the key without a passphrase by running the following command on the Polarity Server:

openssl rsa -in [original.key] -out [new.key]

Replace [original.key] with the name of your current key file and [new.key] with a new name, omitting the brackets ([]) in the command.

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.  

cat new.key

The file content should look similar to this:

-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC1NALrZ6xcgCLO
// Additional Base64 encoded text
-----END PRIVATE KEY-----

Public Key Requirements

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:

cat cert1.crt cert2.crt cert3.crt > server.crt

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 with the "cat" command (cat server.crt) which should look like this:

-----BEGIN CERTIFICATE-----
MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh
// Additional base64 encoded text
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIID7TCCAtWgAwIBAgIJAJlLcgDO1uJuMA0GCSqGSIb3DQEBCwUAMIGMMQswCQYD
// Additional base64 encoded text
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIFCDCCAvCgAwIBAgIIcL7NAf8zejcwDQYJKoZIhvcNAQELBQAwIzEUMBIGA1UE
// Additional base64 encoded text
-----END CERTIFICATE-----

SSL Certificate Installation

The SSL certificate and key should be copied to your Polarity Server in the following locations.  The SSL certificate should be in PEM format.

Filename
Install Location
Polarity Container Specification
server.crt
/app/caddy/config
polarity_web
server.key
/app/caddy/config
polarity_web 
polarity.pem 
/app/certs
polarity_platform 
polarity_key.pem
/app/certs
polarity_platform
<any_ca_chain_filename>.crt
/app/certs/ca
all
Notes
server.crt and polarity.pem are the same file and differ only in their filename and install location.


server.key and polarity_key.pem are the same file and differ only in their filename and install location.

WARNING
The filenames for your certificates must match the filenames provided above.

Only the CA certificates placed in /app/certs/ca may be named arbitrarily, except for having a .crt or .pem extension.

After the certificate and private key are installed in the correct locations listed above, restart the Server's containers. 

cd /app && ./down.sh && ./up.sh

CA Certificate Chains 

If there is a CA certificate chain that your company uses, such as GoDaddy or Zscaler, the full CA cert chain will need to be added to Polarity in order for the Integration Store to work correctly. 

You can see the referenced chain with the following command to check the certificate issuer: 

openssl x509 -in /app/certs/polarity.pem -issuer -noout

Obtain the full CA certificate chain (you can do this through your browser.)  

Add all CA certificates to the /app/certs/ca directory.

Note
The CA cert can have any filename but needs to be in PEM format and end with a .pem or .crt extension.

Once you've added your CA certificates to /app/certs/ca, restart the Server's Docker containers:

cd /app && ./down.sh && ./up.sh
If you do not have the CA chain certificates...
They can typically be found by navigating to the Polarity Server via the browser and clicking on the icon to the left of the URL.  This will pull up a dialog box that will allow you to navigate to the certificates the site is using, and download them.

GoDaddy Certificate Example

The following is an example of downloading the GoDaddy CA certificate and installing it on the server.

mkdir /app/certs/ca
cd /app/certs/ca
wget https://certs.godaddy.com/repository/gd_bundle-g2.crt
cd /app && ./down.sh && ./up.sh

Self-Signed SSL Certificate Generation

If you elect to generate a self-signed SSL certificate, we recommend using the /app/utils/generate_certs.sh script to generate the self-signed cert. 

The script will ask for the FQDN and IP address of the Server, then generate the key pair and put them into the correct locations needed for the v5 server. 

Once the script is complete and the certs have been generated and placed, restart the Docker containers to assimilate the changes: 

cd /app && ./down.sh && ./up.sh

Converting Between Formats

Converting PKCS1 to PKCS8

If you "cat" the private key file, you will see the following on the first line if it is in PKCS1 format:

-----BEGIN RSA PRIVATE KEY-----

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:

openssl pkcs8 -topk8 -inform pem -in <private_pkcs1.pem> -outform pem -nocrypt -out server.key

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.


Similarly, If you "cat" the public key, you will see the following if it is in PKCS1 format:

-----BEGIN RSA PUBLIC KEY-----

To convert the public key from PKCS1 to PKCS8 you can use the following command:

openssl rsa -RSAPublicKey_in -in <public_pkcs1.pem> -pubout -out server.crt

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.

Converting PFX to PEM 

To convert a PFX to a PEM file that will contain both the public and private keys: 

openssl pkcs12 -in filename.pfx -out cert.pem -nodes

From there different portions of the new cert.pem file will need to be copied to the correct locations:

Portion of Cert 
File Name to Copy 
Key Portion 
/app/certs/polarity_key.pem 
First Cert Portion 
/app/certs/polarity.pem 
Remaining Certs Listed in the chain
/app/certs/ca.crt

Other conversion options:

Extract Private key from a PFX to a PEM file: 

openssl pkcs12 -in filename.pfx -nocerts -out key.pem

Export public certificate only:

openssl pkcs12 -in filename.pfx -clcerts -nokeys -out cert.pem

Remove passphrase from the extracted key:

openssl rsa -in key.pem -out server.key

Convert PKCS to PKCS8 

openssl pkcs8 -topk8 -inform PEM -outform PEM -in 
/etc/pki/tls/private/server.key.orig -out 
/etc/pki/tls/private/server.key -nocrypt

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:

openssl x509 -in <cert.cer> -inform DER -text

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:

openssl rsa -inform DER -outform PEM -in <mykey.cer>-out server.crt

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

Public and Private Key Mismatch

If you are seeing the error "Private key does not match Public key", this typically means that there is an error in the certs matching. Run the following commands and compare the MD5 hashes to each other to test this.  

Verify key 

openssl rsa -modulus -noout -in /app/certs/polarity_key.pem | openssl md5

Verify Certificate 

openssl x509 -modulus -noout -in /app/certs/polarity.pem | openssl md5

Verify if the key is valid 

openssl rsa -check -noout -in /app/certs/polarity_key.pem

After running the command, you should see "RSA Key is ok", indicating the key is valid. 

If you are still seeing errors and the key and certs match, please check if there is a passphrase on the key and remove the passphrase.

If there is no pass phrase, please follow the general steps below to check if the docker containers can connect to the certs

General OpenSSL Troubleshooting

These commands will confirm if HTTPS is working and allow you to view the certs the HTTPS server is responding with.

Connect to Docker Shell

docker exec -it polarity_platform bash
docker exec -it polarity_web sh

Verify Polarity_Platform can connect to Polarity_Web 

docker exec -it polarity_platform bash
openssl s_client -connect polarity_web:443 -showcerts

Verify Polarity_Web can connect to Polarity_Platform

docker exec -it polarity_web sh
openssl s_client -connect polarity_platform:4001 -showcerts

Verify Polarity_Web can connect to the Polarity Integration Store 

docker exec -it polarity_web sh
openssl s_client -connect integration-store.polarity.io:443 -showcerts

Integration Store Failures

Integration Store Fails to Load 

If the integration store is failing to load completely, there could be a few issues causing the problem. 

Check and validate the global proxy is set up. 

See the Configuring a Proxy section of the Polarity Documentation for more details.


Check to ensure the polarity_web container can access the Polarity Integration Store 

docker exec -it polarity_web sh
curl -v https://integration-store.polarity.io/api/repos

If there is a successful connection, please check the certificates to ensure they are valid and that the full CA cert chain is added to the server. 

Integration Store Loads but Fails to Install Integrations

If you are able to access the integration store but are not able install integrations and getting an error, the most likely cause is a missing cert in the CA cert chain path. 

Recommend re-checking your CA certificates to ensure the full chain is added to the appropriate locations. 

See CA section above


Was this article helpful?