Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use wsimport when server expects client certificate?

I have a web service using mutual SSL authentication. I can access it just fine in the browser when I have the client's certificate installed.

I need to be able to access this using wsimport for generating the Java code to access the service.

How can I set up my credentials so that I may access the URL using wsimport?

Here's an example of what I'm trying, but it times out due to the inability to authenticate.

wsimport ./sample.wsdl -p com.company.ws.sample -Xnocompile -d ./src -extension -keep -XadditionalHeaders

Thanks for any help

Edit:

This is what wsimport prints. The WSDL is definitely valid, and at the given location, it's a matter of figuring out how to pass in my credentials for authenticating:

wsimport https://wsdl.location.com?WSDL -p com.company.ws.sample -Xnocompile 
-d ./src -extension -keep -XadditionalHeaders


parsing WSDL...

[ERROR] Received fatal alert: handshake_failure

Failed to read the WSDL document: "https://wsdl.location.com?WSDL", because 1) could 
not find the document; /2) the document could not be read; 3) the root element of 
the document is not <wsdl:definitions>.

[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.
like image 816
Cuga Avatar asked Aug 07 '12 14:08

Cuga


1 Answers

You can call directly the WsImport java class (source) and add the JVM necessary args for Java knowing where to look for client certificates.

Something like

java -classpath C:\jdk160_29\lib\tools.jar -Djavax.net.ssl.trustStore=c:\jdk160_29\.mykeystore com.sun.tools.internal.ws.WsImport https://host:8443/Webservice?wsdl -p com.test -s ./src"

should do the trick.

like image 111
David Silva Avatar answered Sep 22 '22 07:09

David Silva