title: axis2 web service client with client certificate
body: <p>I have written a java program which uses axis2 libraries to call a webservice via a stub. This has to be done in a secure way using a client certificate. That's the reason why I was looking for a way to reference my keystore and truststore containing the needed certificates.
  I have searched the internet and found the following lines of code to accomplish the latter request:</p>
  
  <pre><code>File keystoreFile = new File("C:\\storage\\mykeystore");
  URL keystoreURL = keystoreFile.toURI().toURL();
  File truststoreFile = new File("C:\\storage\\cacerts");
  URL truststoreURL = truststoreFile.toURI().toURL();
  Protocol authhttps = new Protocol("https",     newAuthSSLProtocolSocketFactory(keystoreURL, kspwd, truststoreURL, "changeit"), 443);
  Protocol.registerProtocol("https", authhttps);
  
  
  String endpoint = "https://*url_to_endpoint*";
  TestServiceStub stub = new TestServiceStub(endpoint);
  ...
  </code></pre>
  
  <p>When executing my program I receive a handshake error.
  I am not sure if the above lines are sufficient for presenting the client certificate to the invoked web service endpoint. As I am pretty sure that I have set up the keystore and truststore correctly I assume that they perhaps don't get really loaded or applied, but I am not sure.</p>
  
  <p>On the internet I have found a couple of similar requests but didn't find any information leading me to a solution.</p>
  
  <p>So any hint concerning this issue is very welcome.</p>