HTML5GW Docker Container - ERR_CONNECTION_REFUSED with CA Signed Certificates

HTML5GW Docker Container - ERR_CONNECTION_REFUSED with CA Signed Certificates

128
Created On 11/10/26 10:57 AM - Last Modified 11/10/26 16:08 PM


Symptom


When using CA Signed certificates with a certificate private key that has been exported with password protection, running the 'docker run' command without -d does not prompt for the key password.

After running the command, a connection attempt to use the HTML5GW results in the browser displaying 'This site can't be reached' - "ERR_CONNECTION_REFUSED"


Environment


11.4 HTML5 Gateway using Docker with CA Signed certificates where the gateway certificate private key has been password protected.

Cause


The private key cannot be imported into the keystore used by Tomcat without the private key password. The Docker run command does not request the password so the keystore is empty causing Tomcat to fail to initialise the https connector.

Resolution


Prior to continuing, make sure that the PFX file that contains the Certificate private key is in the folder that you have mapped in the docker run command (/opt/cert).

Log into the running container:
**** 
docker exec -ti <container name> bash

Check the tomcat log to confirm whether the https connector failed to start on port 8443:
****
vi /opt/tomcat/logs/catalina.out

There will be an error similar to the following:
****

29-May-2020 12:17:38.477 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["https-jsse-nio-8443"]
29-May-2020 12:17:38.603 SEVERE [main] org.apache.catalina.util.LifecycleBase.handleSubClassException Failed to initialize component [Connector[HTTP/1.1-8443]]
...
   Caused by: java.lang.IllegalArgumentException
...
 Caused by: java.io.EOFException

The EOFException indicates an issue with the keystore.

We need to check to see if the private key was correctly imported into the keystore.
**** 
ls -l /opt/secrets/
total 16
-rw-r--r-- 1 psmgwuser psmgwuser 1870 May 29 11:16 guacdCert.crt
-rw-r--r-- 1 psmgwuser psmgwuser 3272 May 29 11:16 guacdKey.pem
drwxr-xr-x 2 psmgwuser psmgwuser   65 May 29 11:16 import
-rw-r--r-- 1 psmgwuser psmgwuser    0 May 29 11:23 keystore

If the size of keystore is 0, something went wrong during they key import, this is likely caused by the lack of the key password.

We can now recreate the keystore manually.
**** 
mv /opt/secrets/keystore /opt/secrets/keystore.orig

We will re-use the keystore password that was generated during the container creation process and already inserted into the Tomcat server.xml:
**** 
cat /opt/tomcat/conf/server.xml |grep keystorePass

Make a note of the password (without the ""). 
 
Import the certificate private key into the a new keystore.
**** 
keytool \
-importkeystore \
-srckeystore /opt/import/<HTMLGW Certificate>.pfx \
-srcstoretype pkcs12 \
-destkeystore /opt/secrets/keystore \
-deststoretype JKS

Enter destination keystore password:  <keystorePass from server.conf>
Re-enter new password: <keystorePass from server.conf>
Enter source keystore password: <password used when the private key was originally exported>
Entry for alias <key alias> successfully imported.
Import command completed:  1 entries successfully imported, 0 entries failed or cancelled

The <key alias> will be generated randomly during the import process, make a note of it for later.

This command can be used to check the key is imported
**** 
keytool -list -v -keystore /opt/secrets/keystore
Enter keystore password: <keystorePass from server.conf>


We now need to change the password for the key in the keystore to match the one configured in server.conf to allow Tomcat to retrieve it without requiring additional input.
**** 
keytool -keypasswd -keystore /opt/secrets/keystore -alias <key alias>
Enter keystore password: <keystorePass from server.conf>
Enter key password for <key alias>: <password used when the private key was originally exported>
New key password for <key alias>:  <keystorePass from server.conf>
Re-enter new key password for <key alias>:  <keystorePass from server.conf>

Now we need to change the ownership and permissions on the new keystore.
**** 
chown psmgwuser:psmgwuser /opt/secrets/keystore
chmod 644 /opt/secrets/keystore

Finally, restart Tomcat inside the docker container.
****

/opt/tomcat/bin/shutdown.sh
/opt/tomcat/bin/startup.sh

WARNING:
Removing and recreating the docker container will require the above steps to be performed again.
Starting and Stopping the container will not be an issue.


Actions
  • Print
  • Copy Link

    https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA1hj0000001UTtCAM&lang=en_US&refURL=http%3A%2F%2Fknowledgebase.paloaltonetworks.com%2FKCSArticleDetail