Hello,

I am trying to develop a client to connect to a SOAP service. The messages
I need to send to the service have to be signed by a certificate. I have
imported the certificate into my keystore:

c:\Program Files\Java\jdk1.7.0_80>keytool -list -v -keystore
C:\Users\Owner\IdeaProjects\import\keystore.jks
Enter keystore password:
Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: devstore
Creation date: 17/01/2018
Entry type: trustedCertEntry

Owner: CN=***.******.****.au
Issuer: CN=RapidSSL ****** CA, O=GeoTrust Inc., C=US
Serial number: *******************************8
Valid from: Fri Oct 21 13:00:00 ***** 2016 until: Tue Oct 22 12:59:59 *****
Certificate fingerprints:
         MD5:  ....
         SHA1: .....
         SHA256: .....
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 3

Extensions:

#1: ObjectId: 1.3.6.1.4.1.11129.2.4.2 Criticality=false
0000: .....
0010: .....
0020: ......

I think this is related to the :

Map<String, Object> outProps = new HashMap<>();
outProps.put(WSHandlerConstants.ACTION, "Signature");
outProps.put(WSHandlerConstants.USER, "devstore");
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS,
ClientCallbackHandler.class.getName());
outProps.put(WSHandlerConstants.SIG_PROP_FILE, "client_sign.properties");

Because I created ClientCallbackHandler but was not sure how to pass it the
keystore password. I presume it can't find devstore because I haven't
supplied the code to correctly pass the password for the keystore?

public class ClientCallbackHandler implements CallbackHandler {

    @Override
    public void handle(Callback[] callbacks) throws IOException,
            UnsupportedCallbackException {

        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];

        // set the password for our message.
        pc.setPassword("mysecretpassword");
    }
}

The Strack Trace is:

Jan 17, 2018 1:57:46 PM
org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean
buildServiceFromWSDL
INFO: Creating Service {http://tempuri.org/}****** from WSDL: http://******
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
details.
Jan 17, 2018 1:57:47 PM org.apache.cxf.phase.PhaseInterceptorChain
doDefaultLogging
WARNING: Interceptor for {
http://tempuri.org/}*****Service#{urn:******/schema/common}SetEpisode has
thrown exception, unwinding now
org.apache.cxf.binding.soap.SoapFault: Security processing failed.
at
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessageInternal(WSS4JOutInterceptor.java:272)
at
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:136)
at
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:123)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:516)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:425)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:279)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:139)
at com.sun.proxy.$Proxy39.setEpisode(Unknown Source)
at com.CmsExport.createEpisode(CmsExport.java:113)
at com.JFrameTest.writefiletoDB(JFrameTest.java:180)
at com.JFrameTest$FileWorkerThread.run(JFrameTest.java:994)
Caused by: org.apache.wss4j.common.ext.WSSecurityException: Error during
Signature:
Original Exception was org.apache.wss4j.common.ext.WSSecurityException:
Cannot find key for alias: [devstore]
Original Exception was org.apache.wss4j.common.ext.WSSecurityException:
Cannot find key for alias: [devstore]
at
org.apache.wss4j.dom.action.SignatureAction.execute(SignatureAction.java:163)
at org.apache.wss4j.dom.handler.WSHandler.doSenderAction(WSHandler.java:238)
at
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.access$100(WSS4JOutInterceptor.java:55)
at
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessageInternal(WSS4JOutInterceptor.java:264)
... 13 more
Caused by: org.apache.wss4j.common.ext.WSSecurityException: Cannot find key
for alias: [devstore]
Original Exception was org.apache.wss4j.common.ext.WSSecurityException:
Cannot find key for alias: [devstore]
at
org.apache.wss4j.dom.message.WSSecSignature.computeSignature(WSSecSignature.java:595)
at
org.apache.wss4j.dom.action.SignatureAction.execute(SignatureAction.java:155)
... 16 more
Caused by: org.apache.wss4j.common.ext.WSSecurityException: Cannot find key
for alias: [devstore]
at org.apache.wss4j.common.crypto.Merlin.getPrivateKey(Merlin.java:728)
at
org.apache.wss4j.dom.message.WSSecSignature.computeSignature(WSSecSignature.java:538)
... 17 more

Exception in thread "Thread-2" javax.xml.ws.soap.SOAPFaultException:
Security processing failed.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:161)
at com.sun.proxy.$Proxy39.setEpisode(Unknown Source)
at com.CmsExport.createEpisode(CmsExport.java:113)
at com.JFrameTest.writefiletoDB(JFrameTest.java:180)
at com.JFrameTest$FileWorkerThread.run(JFrameTest.java:994)
Caused by: org.apache.wss4j.common.ext.WSSecurityException: Error during
Signature:
Original Exception was org.apache.wss4j.common.ext.WSSecurityException:
Cannot find key for alias: [devstore]
Original Exception was org.apache.wss4j.common.ext.WSSecurityException:
Cannot find key for alias: [devstore]
at
org.apache.wss4j.dom.action.SignatureAction.execute(SignatureAction.java:163)
at org.apache.wss4j.dom.handler.WSHandler.doSenderAction(WSHandler.java:238)
at
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.access$100(WSS4JOutInterceptor.java:55)
at
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessageInternal(WSS4JOutInterceptor.java:264)
at
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:136)
at
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:123)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:516)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:425)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:279)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:139)
... 4 more
Caused by: org.apache.wss4j.common.ext.WSSecurityException: Cannot find key
for alias: [devstore]
Original Exception was org.apache.wss4j.common.ext.WSSecurityException:
Cannot find key for alias: [devstore]
at
org.apache.wss4j.dom.message.WSSecSignature.computeSignature(WSSecSignature.java:595)
at
org.apache.wss4j.dom.action.SignatureAction.execute(SignatureAction.java:155)
... 16 more
Caused by: org.apache.wss4j.common.ext.WSSecurityException: Cannot find key
for alias: [devstore]
at org.apache.wss4j.common.crypto.Merlin.getPrivateKey(Merlin.java:728)
at
org.apache.wss4j.dom.message.WSSecSignature.computeSignature(WSSecSignature.java:538)
... 17 more


Thanks

AG

Reply via email to