Note that there are some explanatory texts on larger screens.

plurals
  1. POResolving javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed Error?
    primarykey
    data
    text
    <p><strong>Edit :-</strong> Tried to format the question and accepted answer in more presentable way at mine <strong><a href="https://tech-geek-passion.blogspot.com/2017/09/how-to-resolve-javaxnetsslsslhandshakee.html" rel="noreferrer">Blog</a></strong> </p> <p>Here is the original issue:-</p> <p>I am getting this error</p> <blockquote> <p>detailed message sun.security.validator.ValidatorException: PKIX path building failed:<br> sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target</p> <p>cause 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</p> </blockquote> <p>i am using tomcat 6 as webserver. i have two https webbapplication installed on different tomcat on differte port but on same machine. Say <code>App1(port 8443)</code> and <code>App2(port 443)</code>. <code>App1</code> connects to <code>App2</code> .When <code>App1</code> connects to <code>App2 i</code> get above error. I know this is very common error so came across many solutions on different forums and sites. I have below entry in <code>server.xml</code> of both tomcat i.e</p> <pre><code>keystoreFile="c:/.keystore" keystorePass="changeit" </code></pre> <p>Every site says the same reason that certificate given by app2 is not in the trusted store of app1 jvm. This seems to be true also when i tired to hit the same URL in IE browser, it works(with warming, There is a problem with this web site's security certificate. here i say continue to this website) But when same url is hit by java client(in my case). So i get the above error. So to put it in trustore i tried these tree options i.e</p> <p><strong>Option1</strong></p> <pre><code>System.setProperty("javax.net.ssl.trustStore", "C:/.keystore"); System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); </code></pre> <p><strong>Option2</strong> Setting below in environment variable</p> <pre><code>CATALINA_OPTS -- param name -Djavax.net.ssl.trustStore=C:\.keystore -Djavax.net.ssl.trustStorePassword=changeit ---param value </code></pre> <p><strong>Option3</strong> Setting below in environment variable</p> <pre><code>JAVA_OPTS -- param name -Djavax.net.ssl.trustStore=C:\.keystore -Djavax.net.ssl.trustStorePassword=changeit ---param value </code></pre> <p><strong>But nothing worked</strong> .</p> <p><strong>What at last worked</strong> is executing the java approach suggested in <a href="https://stackoverflow.com/questions/1828775/httpclient-and-ssl">How to handle invalid SSL certificates with Apache HttpClient?</a> by Pascal Thivent i.e executing the program InstallCert. </p> <p><strong>But this approach is fine for devbox setup but i can not use it at production environment.</strong> </p> <p>I am wondering why three approaches mentioned above did not work when i have mentioned same values in <code>server.xml</code> of <code>app2</code> server and same values in truststore by setting</p> <p><code>System.setProperty("javax.net.ssl.trustStore", "C:/.keystore") and System.setProperty("javax.net.ssl.trustStorePassword", "changeit");</code></p> <p>in <code>app1</code> program.</p> <p>For more information this is how i am making the connection</p> <pre><code>URL url = new URL(urlStr); URLConnection conn = url.openConnection(); if (conn instanceof HttpsURLConnection) { HttpsURLConnection conn1 = (HttpsURLConnection) url.openConnection(); conn1.setHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }); reply.load(conn1.getInputStream()); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload