Caused by: java.security.UnrecoverableKeyException: Cannot recover key

During deployment of my code on server I faced below issue signature issue:

org.apache.axis2.AxisFault: Error in signature with X509Token
    at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:70)
    at org.apache.axis2.engine.Phase.invoke(Phase.java:318)
    at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:254)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:419)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
 Caused by: org.apache.rampart.RampartException: Error in signature with X509Token
    at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignature(AsymmetricBindingBuilder.java:746)
    at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignBeforeEncrypt(AsymmetricBindingBuilder.java:419)
    at org.apache.rampart.builder.AsymmetricBindingBuilder.build(AsymmetricBindingBuilder.java:95)
    at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:147)
    at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:64)
    … 102 more

Caused by: org.apache.ws.security.WSSecurityException: Signature creation failed; nested exception is:
    java.security.UnrecoverableKeyException: Cannot recover key
    at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:721)
    at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignature(AsymmetricBindingBuilder.java:737)
    … 106 more
Caused by: java.security.UnrecoverableKeyException: Cannot recover key
    at sun.security.provider.KeyProtector.recover(KeyProtector.java:311)
    at sun.security.provider.JavaKeyStore.engineGetKey(JavaKeyStore.java:121)
    at sun.security.provider.JavaKeyStore$JKS.engineGetKey(JavaKeyStore.java:38)
    at java.security.KeyStore.getKey(KeyStore.java:763)
    at org.apache.ws.security.components.crypto.CryptoBase.getPrivateKey(CryptoBase.java:216)
    at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:713)
    … 107 more

Above issue is caused by CallbackHandler, because Incorrect password is provided for the private key. Correct the password you are good to go.

About nitingautam

I am Tech Lead (Java/J2EE/ExtJs) with a MNC located @ Gurgaon.
This entry was posted in Axis2, Java, Rampart and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *