How to download power of attorney from classpath with Apache CXF?

I am using Apache CXF (v2.7.3) to invoke a SOAP service through HTTPS. I can load the trust store from a file, but not from the class path - I get the error "Invalid key store format."

I have this configuration in the cfx.xml file:

<http:conduit name="*.http-conduit"> <http:tlsClientParameters> <sec:trustManagers> <!-- For some reason, when I use the resource field, I get a "Invalid keystore format" exception --> <sec:keyStore type="JKS" password="MYPASSWORD" resource="truststore.jks" /> <!-- THIS WORKS FINE: <sec:keyStore type="JKS" password="MYPASSWORD" file="/fullPathToMyTrustStore/truststore.jks" /> --> </sec:trustManagers> </http:tlsClientParameters> </http:conduit> 

I can load the trust store from a file, but not from a class. I can say from the exception that the truststore.jks file is located, but it is not valid. This is a stacktrace of the excluded type.

 Caused by: java.io.IOException: Invalid keystore format at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:633) at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:38) at java.security.KeyStore.load(KeyStore.java:1185) at org.apache.cxf.configuration.jsse.TLSParameterJaxBUtils.getKeyStore(TLSParameterJaxBUtils.java:142) at org.apache.cxf.configuration.jsse.TLSParameterJaxBUtils.getTrustManagers(TLSParameterJaxBUtils.java:292) at org.apache.cxf.configuration.jsse.TLSClientParametersConfig.createTLSClientParametersFromType(TLSClientParametersConfig.java:114) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:149) 
+4
source share
1 answer

I had exactly the same problem, and I blamed CXF at the beginning, but in fact the certificates were not valid for the class path. The first thing to check is that the file in the jar is the same as in the project structure (before packing in the jar).

Suspicions and possible solutions are possible here:

1) If you use Maven, the filtering process can ruin the binaries (my case)

Solution: Exclude certificates from the Maven filtering process, for example:

 <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/*</include> </includes> <excludes> <exclude>**/*.jks</exclude> </excludes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <includes> <include>**/*.jks</include> </includes> </resource> </resources> 

2) If you use the maven-assembly-plugin to create your distribution, this may damage the binaries:

Solution: http://jira.codehaus.org/browse/MASSEMBLY-412

+2
source

All Articles