Java Connecting to azure event hub: SunCertPathBuilderException Java Connecting to azure event hub: SunCertPathBuilderException azure azure

Java Connecting to azure event hub: SunCertPathBuilderException


I searched for your issue and find some helpful blogs which can help solving the issue, please refer to the blogs below.

  1. https://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/
  2. http://nodsw.com/blog/leeland/2006/12/06-no-more-unable-find-valid-certification-path-requested-target

The above blogs all used the tool InstallCert to server certificate that can be added to local keystore. Please follow the README of the GitHub repository.


Download the certificate with your browser and add it to your Java keystore like this:

C:\java\jdk1.8.0_60\jre\lib\security>C:\java\jdk1.8.0_60\jre\bin\keytool.exe -import -alias alias -file C:\path\to\file.crt -keystore C:\java\jdk1.8.0_60\jre\lib\security>cacerts -storepass changeit

You need to make sure to add the cert to the correct Java installation or just add to all installations, given you got more than one.


Turns out it was a stupid network problem. The amqp port is whitelist only.