title: Fatal Error sun.security.validator PKIX path building failed
body: <p>I have faced this issue earlier and got the work around by updating my JDK. Earlier when I faced this issue I was using default installation which I did using Yum and later I downloaded the JDK from oracle and installed it and changed the default $JAVA_HOME path as per the new installation dir. Now the same issue has re-occurred and I have checked the <a href="https://www.google.co.in/search?q=Failure-Fatal%20transport%20error%3asun.security.validator.ValidatorException%3a%20PKIX%20path%20building%20failed%3a%20sun.security.provider.certpath.SunCertPathBuilderException%3a%20unable%20to%20find%20valid%20certification%20path%20to%20requested%20target&amp;oq=Failure-Fatal%20transport%20error%3asun.security.validator.ValidatorException%3a%20PKIX%20path%20building%20failed%3a%20sun.security.provider.certpath.SunCertPathBuilderException%3a%20unable%20to%20find%20valid%20certification%20path%20to%20requested%20target&amp;aqs=chrome.0.57.262&amp;sourceid=chrome&amp;ie=UTF-8" rel="nofollow">related post on the net</a> unable to find any fix. </p>
  
  <p>The sample code which we are using is just simple authentication over http or https. </p>
  
  <pre><code>//Http client object
  HttpClient client = new HttpClient();
  HostConfiguration config = client.getHostConfiguration();
  client.getParams().setParameter("http.socket.timeout", new Integer(100000));
  
  
  String Url = 'https://example.com/';
  PostMethod method = new PostMethod(Url);
  
  //Handler to try for 3 attempt in case of network failure
  method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
                                                                  new DefaultHttpMethodRetryHandler(3, false));
  
  //Here we are trying to connect through Httpclient method
  int statusCode = client.executeMethod(method);
  </code></pre>
  
  <p>Not sure what is causing the issue. </p>
  
  <pre><code>    keytool -list -keystore $JAVA_HOME/jre/lib/security/cacerts
      Enter keystore password:
  
      Keystore type: JKS
      Keystore provider: SUN
  
  Your keystore contains 76 entries
  </code></pre>
  
  <h3>Edited on 11-Feb-2013</h3>
  
  <p>I did some more testing and re-installed my jdk and tomcat too but still getting the same error. </p>
  
  <pre><code>Failure-Fatal transport error:
  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
  </code></pre>
  
  <p>I followed the instruction given on the <a href="http://nodsw.com/blog/leeland/2006/12/06-no-more-unable-find-valid-certification-path-requested-target" rel="nofollow">URL</a> :</p>
  
  <pre><code>java InstallCert services.example.com
  Loading KeyStore jssecacerts...
  Opening connection to services.example.com:443...
  Starting SSL handshake...
  
  No errors, certificate is already trusted
  
  Server sent 1 certificate(s):
  
   1 Subject CN=*.example.com, OU=Domain Control Validated, O=*.example.com
     Issuer  SERIALNUMBER=04343339, CN=Go Daddy Secure Certification Authority, OU=http://certificates.godaddy.com/repository, O="GoDaddy.com, Inc.", L=Scottsdale, ST=Arizona, C=US
  </code></pre>
  
  <p>This shows that the certificate is already added to cacerts. Now this is getting more interesting. </p>