Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
949 views
in Technique[技术] by (71.8m points)

ssl - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...