Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after updating client key file #152

Closed
cgroner opened this issue Jan 7, 2021 · 4 comments
Closed

Error after updating client key file #152

cgroner opened this issue Jan 7, 2021 · 4 comments

Comments

@cgroner
Copy link

cgroner commented Jan 7, 2021

After attempting to update our expiring key with a new key (.p12 Simple Order key, generated from the Enterprise Business Center), we are seeing the following exception:

com.cybersource.ws.client.SignEncryptException: General security error (No certificates for user CyberSource_SJC_US were found for encryption)
 at com.cybersource.ws.client.SignedAndEncryptedMessageHandler.handleMessageCreation(SignedAndEncryptedMessageHandler.java:197)    
 at com.cybersource.ws.client.Client.soapWrapAndSign(Client.java:215)                                                              
 at com.cybersource.ws.client.Client.runTransaction(Client.java:112)                                                               
 at com.cybersource.ws.client.Client.runTransaction(Client.java:68)                                                                
...                                                                
Caused by: org.apache.ws.security.WSSecurityException: General security error (No certificates for user CyberSource_SJC_US were found for encryption) 
 at org.apache.ws.security.message.WSSecEncrypt.prepare(WSSecEncrypt.java:174)                                                     
 at org.apache.ws.security.message.WSSecEncrypt.build(WSSecEncrypt.java:223)                                                       
 at com.cybersource.ws.client.SignedAndEncryptedMessageHandler.handleMessageCreation(SignedAndEncryptedMessageHandler.java:194)

This was running on the SDK 6.2.3, But I believe I was also able to reproduce the problem using only the nvp RunSample class provided in the 6.2.10 SDK, which generates the following back trace:

Exception in thread "main" java.lang.NullPointerException
	at com.cybersource.ws.client.SecurityUtil.handleMessageCreation(SecurityUtil.java:204)
	at com.cybersource.ws.client.Client.soapWrapAndSign(Client.java:240)
	at com.cybersource.ws.client.Client.runTransaction(Client.java:117)
	at com.cybersource.ws.client.Client.runTransaction(Client.java:67)
	at com.cybersource.sample.RunSample.runAuth(RunSample.java:150)
	at com.cybersource.sample.RunSample.main(RunSample.java:57)

Restoring our previous key resolves the issue. I have also tried regenerating the key, which all appear to be valid keys, without success.

@cgroner
Copy link
Author

cgroner commented Jan 8, 2021

Transactions will complete successfully if useSignAndEncrypted=false, but this seem like more of a workaround than a fix.

@cgroner
Copy link
Author

cgroner commented Jan 8, 2021

I also believe, like suggested in #151 , that something appears to have changed in the keystore generation method.

When iterating over the entries of our previous (working) keystore here, it iterates over multiple entries including the named certificates reported missing.

When using the new keystore, only 1 entry (for the key) is found. Later, when an attempt is made to use the named certificate for signing, it's not found in the identities Map, resulting in the NullPointerError.

Inspecting both keystores using the openssl shows they each contain multiple certificates. i.e.:
openssl pkcs12 -info -in <keystore>.p12

Comparing our working and not-working certificates using this method, one difference I notice is the lack of 'friendlyName' properties in the certificate entries. Can you confirm whether or not this attribute is is what's being used to name the 'Alias' entries in the keystore? Is it possible the missing friendlyName properties are causing it to not correctly iterate over the parsed keystore entries?

@mahendya1002
Copy link
Contributor

Could you please generate the new key and see if it works ?

@cgroner
Copy link
Author

cgroner commented Feb 5, 2021

Generating a new key does appear to have resolved the issue.

Thank you.

@cgroner cgroner closed this as completed Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants