title: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed
body: <p>i am using java application to check the url connrectivity, for the some url (internal) application url, i am getting 200 (success), for the others i am getting the below exception.</p>
  
  <p>but if i manually connect to the below url , no issues on that, do i need pki certificates.
  need your help.</p>
  
  <h2>URL Link  response code (200), good</h2>
  
  <p><a href="http://pns15a-0215.corpny.com:21212/Mngr" rel="nofollow">http://pns15a-0215.corpny.com:21212/Mngr</a> 200 OK OK </p>
  
  <h2>URL link response exception</h2>
  
  <p><a href="https://tantex.intra.net/Mngr/" rel="nofollow">https://tantex.intra.net/Mngr/</a> </p>
  
  <p>Exception message:
  sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target</p>
  
  <h2>Logs</h2>
  
  <p>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  at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)     at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)     at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)     at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)  at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)</p>
  
  <h2>Program Source code</h2>
  
  <pre><code>        log.info("testing the httpurlconnection for url:" + strUrl );
  
              url = new URL(strUrl);
              urlConn = (HttpURLConnection) url.openConnection();
              urlConn.connect();
  
              if (urlConn.getResponseCode() == HttpURLConnection.HTTP_OK )
              {
                  log.info("url http connection is sucessfull");
  
                  //append the response status
                  urlResponseStatus = "OK";
              }
              else
              {
                  log.info("url http connection failure, response code:" +  urlConn.getResponseCode());
  
                  //append the response status
                  urlResponseStatus = "NOT OK";
              }
  
              urlResponseCode = urlConn.getResponseCode();
              urlResponseMessage =  urlConn.getResponseMessage();
  </code></pre>