title: WsImport unable to find imported certificate
body: <p>Apologies for yet another "unable to find certificate" question.</p>
  
  <p>I'm developing on a Windows 7 machine. I am using multiple Java versions and because of that am explicit about paths to the used java version (here Java6). I achieve this by the following two lines:</p>
  
  <pre><code>set path=c:\Program Files\Java\jdk1.6.0_45\bin;%path%
  set java_home=c:\Program Files\Java\jdk1.6.0_45
  </code></pre>
  
  <p>I need to use a 3rd party web service <a href="https://service.gov/Service.svc?wsdl" rel="nofollow">https://service.gov/Service.svc?wsdl</a> that provides a certificate.PFX certificate (both service URI and certificate file are renamed as a way to protect the 3rd party's interests). I have made sure that after importing the certificate file in Windows I can open the WSDL file in my browser.</p>
  
  <p>I first import the certificate in my keystore (using Administrator Command Prompt to get access to write in the system folder):</p>
  
  <pre><code>keytool -importkeystore -srckeystore certificate.pfx -srcstoretype pkcs12 -keystore "c:\Program Files\Java\jdk1.6.0_45\jre\lib\security\cacerts"
  </code></pre>
  
  <p>I get a success notification. Still, I make sure that the new certificate is present in the output of:</p>
  
  <pre><code>keytool -list -keystore "c:\Program Files\Java\jdk1.6.0_45\jre\lib\security\cacerts"
  </code></pre>
  
  <p>Then I create a new folder containing blank subfolders called src and classes. Once this is done, I run wsimport from that new folder (using Java class instead of binary to make sure I am explicit about the truststore being used):</p>
  
  <pre><code>java -classpath "c:\Program Files\Java\jdk1.6.0_45\lib\tools.jar" -Djavax.net.ssl.trustStore="c:\Program Files\Java\jdk1.6.0_45\jre\lib\security\cacerts" -Djavax.net.ssl.trustStorePassword=changeit com.sun.tools.internal.ws.WsImport https://service.gov/Service.svc?wsdl -s src -d classes
  </code></pre>
  
  <p>The output is the following:</p>
  
  <pre><code>parsing WSDL...
  
  [ERROR] sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
  
  Failed to read the WSDL document: https://service.gov/Service.svc?wsdl, because 1) could not find the document; /2) the document could not be read; 3) the root element of the document is not &lt;wsdl:definitions&gt;.
  
  [ERROR] failed.noservice=Could not find wsdl:service in the provided WSDL(s):
  
  At least one WSDL with at least one service definition needs to be provided.
  
  Failed to parse the WSDL.
  </code></pre>
  
  <p>The WSDL file contains  and is used by other organisations, so the problem is pretty certainly not on the 3rd party's side.</p>
  
  <p>Am I missing something? To me it all seems obvious by now, but it still doesn't work. I have also tried this with Java8, and the result is pretty much the same. The only difference is that in Java8, the WsImport class no longer exists, so I am using the wsimport.exe binary.</p>
  
  <p>Thanks in advance for any ideas or hints.</p>