title: How to convert a pfx file into jks and then use it to sign an outgoing soap request by using the classes generated from a wsdl
body: <p>I am looking for a code example which shows how to access a secure web service over SSL using a PFX certificate. 
  I have the certificate and its password and I started by creating a KeyStore instance using the command mentioned below.</p>
  
  <pre><code>keytool -importkeystore -destkeystore "C:\Program Files\Java\jdk1.8.0_131\jre\lib\security\dvs.keystore" -srckeystore "C:\Program Files\Java\jdk1.8.0_131\jre\lib\security\key.pfx" -srcstoretype pkcs12 -deststoretype JKS -srcstorepass *******
  </code></pre>
  
  <p>I then used 
  <code>wsimport -keep -verbose -extension https://sandpit.dvshub.com.au:19443/Bus/VerificationServiceBus.svc?wsdl</code> 
  command to generate Java files.</p>
  
  <p>After which I created a main class in which I specified several parameters such as the location of these certificates.</p>
  
  <pre><code>        System.setProperty("javax.net.ssl.trustStore", trustStoreFile);
          System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
  
          System.setProperty("javax.net.ssl.keyStore", certificateFile);
          System.setProperty("javax.net.ssl.keyStorePassword", certificatePassword);
          System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
  
          System.setProperty("javax.net.ssl.keyStore", "C:\\Users\\Administrator\\Desktop\\dvs\\key.pfx");
          System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
          System.setProperty("javax.net.ssl.keyStorePassword", certificatePassword);
  </code></pre>
  
  <p>Then I eventually called the web method that was created by wsimport using the service it generated.</p>
  
  <pre><code>CreatedService service = ServiceFactory/Port/Creator.getCreatedService(); // Where 'CreatedService' and 'ServiceFactory/Port/Creator' were created by wsimport: this code entirely depends on the WSDL provided.
  service.[ws method](...);
  </code></pre>
  
  <p>I then created a handler to keep track of what is being passed inside the header but I cannot see any signature being added to it at all. Am I missing something over here. I am only getting request timed out errors.</p>
  
  <p>I have a working example of it in Soap UI so I know that the service is running properly.</p>
  
  <p>Any help with this would be very much appreciated. Please point me in the right direction as I am ready to try anything at this point.</p>
  
  <p>Thanks in advance.</p>
  
  <p>[Edit] 
  Is WSO2 Application server the way to go : <a href="https://docs.wso2.com/display/AS530/WS-Security+Sample+on+Signature+and+Encryption" rel="nofollow noreferrer">Reference</a></p>
  
  <p>This is where I picked up my current approach <a href="https://coderanch.com/t/498320/java/implement-certificate-security-web-service" rel="nofollow noreferrer">Reference</a></p>