What was the Issue

Attempting to access applications that are encrypted with SSL (for example HTTPS, LDAPS, IMAPS) throws an exception and the connection is refused. This can happen when attempting to establish a secure connection to any of the target i.e. Azure, SalesForce, Active Directory etc.

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

How to diagnosis

Download SSLPoke

Set Java Class path

export JAVA_HOME=<Java Path>
export PATH=$JAVA_HOME/bin:$PATH

Compile SSLPoke Java class

javac SSLPoke.java

java SSLPoke HOSTNAME PORT

i.e. java SSLPoke graph.microsoft.com 443

SSL connectivity check with keystore

java -Djavax.net.ssl.trustStore=$JAVA_HOME/jre/lib/security/cacerts SSLPoke login.microsoft.com 443

java -Djavax.net.ssl.trustStore=<Path to trust store>.jks SSLPoke login.microsoft.com 443

Pradeep Ankireddy

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store