PKIX path building failed: Exception

Exception:

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.”

 Whenever we are trying to connect with cloud sites or systems, we will face this issue due to a firewall that prevents us from connecting to the systems, due to an invalid certification.

This will take some considerable time when we try to solve it. We have come up with the best suitable solution to solve this exception.

Just go through the steps provided below to solve the issue

  1. Download the certificate from the target systems you want to connect
  2. Install the certificate in java certificate path.
  3. Point to the java version where you have installed the certificate
  4. Restart the application
  5. Now your integration will connect to the target systems successfully.

 

  1. Download the Certificate from The Site You Want to Connect

We just need to go to the website and we will find a lock symbol on the left side of the address bar

Click on the lock symbol, it will pop up a window with security, cookies, and site setting options

Click on the connection is a secure option

It will redirect to another popup here we need to click on the “certificate is valid” icon.

In another popup, we will have an option to export the certificate, on the bottom right side of the popup.

After clicking on the export button,

It will redirect us to save the certificate, as shown below save the certificate with a file name as a “meaningful name” and type as a “DER-encoded binary”.

In my case,

I have saved it as magento2, in a directory “C:\Users\Veera\Downloads\magento2.der”

 

  1. Install the certificate in java cert path.

To install the certificate, we need to run the command prompt as administrator.

We have to use the following command, to install the certificate in our local java certificates path

keytool -importcert -trustcacerts -alias filename-file “filepath where we downloaded the certificate” -keystore “java library security path to install the certificate” -storepasschangeit

In my case, this is how command looks like,

keytool -importcert -trustcacerts -alias magento2 -file “C:\Users\Veera\Downloads\magento2.der” -keystore “C:\Program Files\Java\jdk1.8.0_202\jre\lib\security” -storepasschangeit

Let’s execute the command

After executing the command, it will prompt the Trust this certificate?

Then we have to enter it as YES,

After this step,

It will show the certificate was added tokeystore response

  1. Point to the java version where you have installed the certificate

 If the java in anypoint studio is not pointing to the java where you have installed the certificate,

You can check and change the directory, by following the below steps.

  • Go to any point studio, windows tab selects the preferences a popup will appear.
  • Then navigate to the java on the left of the popup.
  • Under java, you will find Installed JREs
  • You will find the available JREs on the left side, make sure it is not pointing to your required java location.
  • If not, click on the add button on the right of the pop-up. It will open another popup.
  • In that select standardVM as JAR type, and it will open another popup
  • In the popup, we will find the option to select the JRE Home directory.
  • Complete it and finish it

In my case, I have given the screenshots to set the java home in any point studio.

Restart the application

To apply the changes, restart the application. probably it will solve the Exception

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.”

For more details, contact us today.