Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.Exception: Public keys in reply and keystore don't match

I have to access a webservice hosted at port 443.Service provider has shared three certificate with us.

  1. ABCD.cer
  2. CA_Certificate.cer
  3. CCA_Certificate.cer

I have to add them to keystore by creating a form chain for the SSL communication.I have followed below steps.

  1. keytool -keystore npci_keystore_test.jks -genkey -alias npci_client_testore

       Result :- keystore npci_keystore_test.jks created.
    
  2. keytool -import -keystore npci_keystore_test.jks -file CA_Certificate.cer -alias theCARoot

       Result :- certificate CA_Certificate.cer is added to keystore.
    
  3. keytool -import -keystore npci_keystore_test.jks -file CCA_Certificate.cer -alias theCCARoot

       Result :- certificate CCA_Certificate.cer is added to keystore.
    
  4. keytool -import -keystore npci_keystore_test.jks -file ABCD.cer -alias npci_client_testore

    At the step 4 i have below exception

    Enter keystore password: (and when i enter password i have below exception)

    keytool error: java.lang.Exception: Public keys in reply and keystore don't match

I have already done search in SO,but so far no luck.

I am following below source to create the store and import certificate in it. JKS Keystore

EDIT:---

I have tested it by changing the import order of certificate,but no luck so far.

like image 706
dReAmEr Avatar asked Jan 02 '15 12:01

dReAmEr


1 Answers

The issue here is the alias you used while importing the certificate which is similar to the one you used while creating the JKS store. Just change the alias and it will solve your issue. The source document [1] needs to be corrected accordingly.

[1] http://docs.oracle.com/cd/E19509-01/820-3503/ggfgo/index.html

like image 198
Ravindra Ranwala Avatar answered Nov 02 '22 23:11

Ravindra Ranwala