ValidatorException: PKIX path building failed

When using self-signed certificates you might come across the following error: > "javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"

To solve this, you need to import the untrusted certifcate in to Java's keystore. Begin by executing the following command:

openssl s_client -showcerts -connect 192.168.200.161:8006

Create a new file called root.crt and paste everything between:

-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----

Save root.crt on your desktop and import into Java keystore with the following command:

sudo keytool -importcert -keystore /etc/java-8-oracle/security/cacerts -storepass changeit -file ~/Desktop/root.crt -alias "rhel-root"