title: SOAP client over SSL: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
body: <p>I am working with remoted SOAP service through the HTTPS (HTTP over SSL) and I've generated my client classes with axis <code>WSDL2java</code> tool. So, I use Axis2 client, i have tried Axis too, here wasn't difference between them 
  I have selfmade certificate in .pfx just for developing.
  First I've tried to make request through the SoapUI, and i just add my certificate and password in SSLsettings:</p>
  
  <p><img src="https://i.stack.imgur.com/eIEqd.jpg" alt=""></p>
  
  <p>And that works fine.</p>
  
  <p>After that I've tried to make request with my Axis client  through the Java code. Before sending request I've added:</p>
  
  <pre><code>System.setProperty("javax.net.ssl.keyStore", "C:\work\example.pfx");
  System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
  System.setProperty("javax.net.ssl.keyStorePassword", "myPassw");
  System.setProperty("javax.net.ssl.keyStoreProvider", "SunJSSE");
  </code></pre>
  
  <p>After that I sent request with my client:</p>
  
  <pre><code>SMTHExample_ServiceStub client = 
  new SMTHExample_ServiceStub("https://ipaddr:10443/anotherpartOfUrl");
  Info2Resp gi2resp = client.getResp2(getSmth2);
  </code></pre>
  
  <p>And after that i got an exception:</p>
  
  <blockquote>
    <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</p>
  </blockquote>
  
  <p>After that i've tried to run my class with SoapUI's jre, but it didn't help, I got exactly the same error.</p>
  
  <p>I also tried to use different workarounds like <code>org.apache.axis2.java.security.TrustAllTrustManager</code> to disregard the certificate and trust the server, but they didn't help too.</p>
  
  <p>Launching the Client with <code>-Djavax.net.debug=ssl,keymanager</code> show in both cases:</p>
  
  <pre><code>keyStore is : C:\work\example.pfx
  keyStore type is : PKCS12
  keyStore provider is : SunJSSE
  init keystore
  init keymanager of type SunX509
  ...here going init... 
  trustStore is: path/to/jre/lib/security/cacerts/mine/or/SoapUI's
  trustStore type is : jks
  trustStore provider is : 
  init truststore
  ...here are added all trusted certs...
  </code></pre>
  
  <p>And I don't  know is it important but after adding certs I saw in log: </p>
  
  <pre><code>trigger seeding of SecureRandom
  done seeding SecureRandom
  Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
  Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA
  Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
  Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
  Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
  Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
  Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
  Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
  Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
  Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
  Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256
  Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
  Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
  Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
  Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA
  Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
  Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
  Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
  Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
  Ignoring unavailable cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA
  Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_128_CBC_SHA256
  </code></pre>
  
  <p>And after all, as I understand, during the handshake i got in log </p>
  
  <pre><code>%% Invalidated:  [Session-1, SSL_RSA_WITH_RC4_128_SHA]
  main, SEND TLSv1 ALERT:  fatal, description = certificate_unknown
  main, WRITE: TLSv1 Alert, length = 2
  main, called closeSocket()
  main, handling exception: 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>