- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
Our community just got stronger! Explore new identity security resources, connect with experts, and discover more ways to learn and collaborate.
The purpose of this document is to provide Idira customers, partners, and employees with a detailed description of the process for securing a deployment of the Idira PSM HTML5 Gateway using certificates.
The examples given are based on the Idira Training Skytap environment with the fictitious ACME Corporation, with which all of our customers and partners should be familiar.
Specifically, in this document we will see how to:
Note: This document has been tested in a Idira PAM version 14.4 Self-Hosted environment with a PSM Gateway server running Rocky 9.4
The following steps assume you have already deployed, but not configured, the Tomcat web application (version 9.x).
You can generate the certificate for the Guacamole web app, which in our case means the HTML5 Gateway either outside the server and then copy the files to the psm-gw server, or directly on the server itself. Generally speaking, it is more secure NOT to move the private keys, so the process below describes how to do it directly on the server.
First, create a sub-directory to hold the keystore and then change directories into that sub-directory.
mkdir /opt/tomcat/keystorecd /opt/tomcat/keystore
Next, we will generate the actual keystore. This will launch a wizard that will step us through the process of gathering most of the information required to create a certificate for the psm-gw.acme.corp server.
Create a keystore file to store the certificate private keys securely.
keytool -genkey -alias tomcat -keyalg RSA -keysize 2048 -keystore tomcat.jks
Prompts for a password twice and then it presents a list of questions that will form the basis of the certificate.
Answer some questions:
What is your first and last name?[Unknown]: psm-gw.acme.corpWhat is the name of your organizational unit?[Unknown]: TrainingWhat is the name of your organization?[Unknown]: AcmeWhat is the name of your City or Locality?[Unknown]: NewtonWhat is the name of your State or Province?[Unknown]: MAWhat is the two-letter country code for this unit?[Unknown]: USIs CN=psm-gw.acme.corp, OU=Training, O=Acme, L=Newton, ST=MA, C=US correct?[no]: yes
Enter key password for <tomcat>(RETURN if same as keystore password):
At the end, you will be prompted to export the keystore to PKCS12, which you should do. You can copy and paste the command from the last output. This will create a backup of the old keystore and use the same name – tomcat.jks – for the new PKCS12 keystore.
keytool -importkeystore -srckeystore /opt/tomcat/keystore/tomcat.jks -destkeystore /opt/tomcat/keystore/tomcat.jks -deststoretype pkcs12
Now we can generate a CSR based on the information in the keystore and some extra information (the Subject Alternative Name, or SAN). You will be prompted for the keystore password.
keytool -certreq -keyalg RSA -alias tomcat -file /opt/tomcat/keystore/psm-gw.csr -keystore /opt/tomcat/keystore/tomcat.jks -ext SAN=dns:psm-gw.acme.corp,dns:psm-gw,ip:10.0.30.3
Note: Chrome, at least, seems to require something in the SAN field. Here, it is two DNS names plus the IP address of the certificate. That works. If excluded, Chrome sees the certificate as invalid.
You should now have three files in your /opt/tomcat/keystore directory:
You now need to present your CSR to your certificate authority for signature. Because that process will differ from organization to organization, it is beyond the scope of this document.
Once the certificate is signed, you need to copy it back to the psm-gw server in order to import it into the keystore. You will also need to copy the certificates for the entire trust chain. In our example, we have only to import psm-gw.cer and acme.cer because we use our Root CA to sign our certificates. This is NOT best practice.
Copy those files into the directory /opt/tomcat/keystore for convenience.
First, import the CA certificate. You would need to modify the -alias parameter for each link in the trust chain as you imported them: -alias intermediate1, -alias intermediate2, etc. From the /opt/tomcat/keystore directory, run the following:
keytool -import -alias root -keystore tomcat.jks -trustcacerts -file acme.cer
You will be prompted for the keystore password. Then, you will be presented with the details of the certificate and asked to confirm the import. Enter yes.
Trust this certificate? [no]: yes
Then import the server certificate. Again, you will be prompted for the keystore password.
keytool -import -alias tomcat -keystore tomcat.jks -file psm-gw.cer
This does not require confirmation.
The process for configuring tomcat is detailed in CyberArk’s on-line documentation:
Install PSM HTML5 Gateway using an RPM package | Idira Docs
There is no need to repeat it here. If you performed the steps above, then you can ignore any steps in the documentation related to Tomcat certificates. You still need to configure the server.xml file.
Deploy the Gateway as per instructions in the documentation.
The Guacamole service – guacd – needs to communicate securely with the web app tomcat. We can use the same certificate we generated for Tomcat, but we will need a copy of it in another location and in a slightly different format.
The guacd service also needs access to the private key for this certificate, so we will need to extract it from the Tomcat keystore and then convert it to a format that is readable by Guacamole.
The instructions in this section have some overlap with the on-line documentation. However, the process described here is adapted to CA-signed certificates, as opposed to self-signed certificates.
Find the location of the JVM keystore:
readlink -f /usr/bin/java | sed "s:bin/java::"
This returns a path that will look something like this (the version may be different):
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.442.b06-2.el9.x86_64/jre
You will then insert that string into another command to import first the root certificate (highlighted below):
keytool -import -alias acme_root_cert -keystore /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.442.b06-2.el9.x86_64/jre/lib/security/cacerts -trustcacerts -file /opt/tomcat/keystore/acme.cer
Note: If the root of your trust chain is a public CA, then its certificate should already be in the machine's certificate store and you would not need to import it.
Do this for the entire trust chain in the order of the hierarchy: root, first intermediate, second intermediate, etc.
keytool -import -alias webapp_guacd_cert -keystore /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.442.b06-2.el9.x86_64/jre/lib/security/cacerts -trustcacerts -file /opt/tomcat/keystore/psm-gw.cer
This will allow the local machine to trust the acme.corp CA.
Copy the CA cert to the local certificate folder:
cp /opt/tomcat/keystore/acme.cer /etc/pki/ca-trust/source/anchors/
Then update the CA store
update-ca-trust extract
Prepare the files for Guacamole
We need to prepare the files for use by Guacamole, which has slightly different requirements.
Change directories back into the Tomcat keystore:
cd /opt/tomcat/keystore
Then, export the tomcat.jks to a PFX file for guacd. The command “imports” the data to a new keystore of format PKCS12. As such, you will be prompted twice to create a password for the new keystore, then you will be prompted once for the password to the source keystore.
keytool -importkeystore -srckeystore tomcat.jks -destkeystore psm-gw.pfx -srcstoretype JKS -deststoretype PKCS12
Now that the data is outside the tomcat keystore, we can manipulate it with openssl commands.
Extract the certificate and keys to a PEM file. You will first be prompted for the PFX password, then to create a password for the PEM file.
You will need to include the -legacy switch, as shown below.
openssl pkcs12 -in psm-gw.pfx -nocerts -out psm-gw.pem -legacy
Then extract the certificate in .crt format. For some reason, Guacamole does not like the certificate in .cer format. You will be prompted for the PFX password.
openssl pkcs12 -in psm-gw.pfx -clcerts -nokeys -out psm-gw.crt -legacy
Then extract the PEM file to a KEY file. You will be prompted for the PFX password.
openssl rsa -in psm-gw.pem -out psm-gw.key
Create a directory to hold the certificate and private key for Guacamole.
mkdir /opt/certs
Copy the certificate and key file to from /opt/tomcat/keystore to our newly created certificate directory.
cp psm-gw.crt /opt/certs/psm-gw.crtcp psm-gw.key /opt/certs/psm-gw.key
Make the two files readable:
chmod 644 /opt/certs/psm-gw.crtchmod 640 /opt/certs/psm-gw.key
Make the PSM Gateway user owner of the Guacamole certificate directory:
chown -R psmgwuser:psmgwuser /opt/certs/
Edit the guacd config file to point to these new files:
vi /etc/guacamole/guacd.conf
Update the file so that the SSL section is active and the two parameters point to your two files.
[ssl]
server_certificate = /opt/certs/psm-gw.crtserver_key = /opt/certs/psm-gw.key
Restart Tomcat and restart Guacamole:
systemctl restart tomcatsystemctl restart guacd