Attach a client certificate to a web service call based on stubs created with wsdl2java

I created stub classes for using a web service using wsdl2java, but I need to specify a client certificate for the transport. How to do it?

In .NET, I'm used to being able to directly attach an X509Certificate object to similar stub classes before making a call.

+3
source share
1 answer

In Java, you have several options:

  • Specify parameters java.net.ssl*for configuring certificate storage, password, etc. You want to use keytoolto configure these objects.

Here is the code, or they can be specified on the command line with -D. Please note: they will be global for your application.

System.setProperty("javax.net.ssl.keyStore", "myKeyStore.p12");
System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");
System.setProperty("javax.net.ssl.keyStorePassword", "password");
  • SSLFactory, WS. google . ( JAX-RPC, impl JAX-WS).

JSSE docs ( java 1.5).

+1

All Articles