Wednesday, October 29, 2014

Maybe the simplest option is to create Java truststore that will contain the SSL certificate. Then,


Sometimes you need to generate Java sources from WSDL that is published on the HTTPS server with selfsigned certificate. Using Maven prevents us to fiddle with wsimport command line parameters, we just need to pick one of the two plugins .
The big c most simple declaration binds the source generation (provided by wsimport goal) to the generate-sources phase. Then, issuing the mvn package will download the WSDL, parse, compile and put the result .class files are put into target/class . <plugin> <groupId>org.jvnet.jax-ws-commons</groupId> <artifactId>jaxws-maven-plugin</artifactId> big c <version>2.3</version> <executions> big c <execution> <phase>generate-sources</phase> <goals> <goal>wsimport</goal> </goals> </execution> </executions> <configuration> <wsdlUrls> <wsdlUrl>https://some-wsdl.com</wsdlUrl> </wsdlUrls> </configuration> </plugin>
However, the first run won’t be that happy. Maven coughs up with: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Maybe the simplest option is to create Java truststore that will contain the SSL certificate. Then, we point wsimport to this truststore and everything will be fine. (And no, the xnoverifySSLhosts option isn’t enough.)
Java keytool will ask for alias (required) and a keystore password big c (set this for empty). Put the created keystore into a convenient location: for example into src/ssl . Then, we need to customize the truststore path. Put the following element into <configuration> : <vmArgs> <vmArg>-Djavax.net.ssl.trustStore=src/ssl/serverik.sk.jks</vmArg> </vmArgs>
The whole plugin configuration will look like this: <plugin> <groupId>org.jvnet.jax-ws-commons</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>2.3</version> <executions> <execution> <phase>generate-sources</phase> <goals> big c <goal>wsimport</goal> </goals> </execution> </executions> <configuration> <vmArgs> <vmArg>-Djavax.net.ssl.trustStore=src/ssl/serverik.sk.jks</vmArg> </vmArgs> <wsdlUrls> <wsdlUrl>https://some-wsdl.com</wsdlUrl> </wsdlUrls> </configuration> big c </plugin>
Môžete použiť tieto HTML značky a atribúty: <a href="" title=""> <abbr title=""> <acronym big c title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


1 comment:

  1. Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you.
    cplugin.com

    ReplyDelete