<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z00007ybAiSCAUOkta Classic EngineAPI Access ManagementAnswered2024-04-02T16:23:39.000Z2022-08-19T09:52:00.000Z2022-08-29T06:21:05.000Z

mihirk.61757 (Customer) asked a question.

PKIX path building failed while invoking OKTA API for access token.

Hello,

we are getting below error while invoking API for access token from our code.

Wealready have imported required certificate in Java home.

 

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

javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.

 

We are trying to test OpenID connect integration through OKTA. Below is the required code snippet.

 

HttpPost httppost = new HttpPost("https://dev-15411581.okta.com/oauth2/v1/token");

 

         httppost.setHeader("content-type", "application/x-www-form-urlencoded");

          postParameters = new ArrayList<NameValuePair>();

          postParameters.add(new BasicNameValuePair("grant_type", "authorization_code"));

          postParameters.add(new BasicNameValuePair("code", code));

          postParameters.add(new BasicNameValuePair("redirect_uri", "http://localhost:8080/Inside"));

          postParameters.add(new BasicNameValuePair("client_id", "0oa60ln2uiYjJWHBM5d7"));

          postParameters.add(new BasicNameValuePair("client_secret", "LDYhkim1E-PhqTu3lH0KIqHgsa9C-vdzxSvtjSQw"));

          postParameters.add(new BasicNameValuePair("code_verifier", "qjrzSW9gMiUgpUvqgEPE4_-8swvyCtfOVvg55o5S_es"));

          httppost.setEntity(new UrlEncodedFormEntity(postParameters, "UTF-8"));

 

Regards

Mihir


  • JaniK.29243 (Customer)

    Hi @mihirk.61757 (Customer)​,

     

    Have you tried to specify the certificate store by using "-Djavax.net.ssl.trustStore=" JVM flag?

     

    You can also use e.g. this "-Djavax.net.debug=handshake:ssl" flag to troubleshoot SSL connections. You could use "-Djavax.net.debug=all" as well, but it is too verbose - in my opinion.

     

    -Jani

    Expand Post
  • mihirk.61757 (Customer)

    Thanks Jani

    with the same configuration changes as per the shared, it worked !!

This question is closed.
Loading
PKIX path building failed while invoking OKTA API for access token.