keytool错误:java.io.IOException:密钥库密码不正确
为Tomcat创建了一个证书,试图将其安装到新的密钥库中,但出现错误(编辑:使用-v选项运行,现在获取更多信息): 遗憾的是,这是正确的,密码短语有两个“®”。那么,考虑到我所做的(私钥具有非ASCII密码),从中恢复会有多痛苦keytool错误:java.io.IOException:密钥库密码不正确,java,tomcat,certificate,keystore,keytool,Java,Tomcat,Certificate,Keystore,Keytool,为Tomcat创建了一个证书,试图将其安装到新的密钥库中,但出现错误(编辑:使用-v选项运行,现在获取更多信息): 遗憾的是,这是正确的,密码短语有两个“®”。那么,考虑到我所做的(私钥具有非ASCII密码),从中恢复会有多痛苦 1: Create a passphrase file: vi .kp 2: Make CSR: A: Generate a 2048 bit private key: openssl genpkey -algorithm RSA -outform PEM -out m
1: Create a passphrase file: vi .kp
2: Make CSR:
A: Generate a 2048 bit private key:
openssl genpkey -algorithm RSA -outform PEM -out mike.privateKey.pass.pem -pkeyopt rsa_keygen_bits:2048 -pass file:.kp
B: Make the CSR:
openssl req -new -sha256 -key mike.privateKey.pass.pem -out mike.ike.com.cert.csr
Note: CSR has different "challenge password" than in the passphrase file, if that matters
3: Submit CSR to Comodo
4: Get certificate file mike_ike_com.cer & Comodo trust chain files: COMODORSAOrganizationValidationSecureServerCA.crt, COMODORSAAddTrustCA.crt, AddTrustExternalCARoot.crt
5: Convert the Certificates:
A: Convert to PEM:
openssl x509 -inform DER -in COMODORSAOrganizationValidationSecureServerCA.crt -out COMODORSAOrganizationValidationSecureServerCA.pem -outform PEM
openssl x509 -inform DER -in COMODORSAAddTrustCA.crt -out COMODORSAAddTrustCA.pem -outform PEM
openssl x509 -inform DER -in AddTrustExternalCARoot.crt -out AddTrustExternalCARoot.pem -outform PEM
B: Concat into a single file:
cat COMODORSAOrganizationValidationSecureServerCA.pem COMODORSAAddTrustCA.pem AddTrustExternalCARoot.pem > Comodo.root.crt
C: Use openssl to create a pkcs12 file:
openssl pkcs12 -export -in mike_ike_com.cer -inkey mike.privateKey.pass.pem -passin file:.kp -out mike_ike.p12 -name tomcat -caname root -chain -CAfile Comodo.root.crt
Note: when it asks "Enter Export Password" I give it the pw from .kp
6: Use keytool to create the keystore file:
$JAVA_HOME/bin/keytool -importkeystore -deststorepass:file .kp -destkeypass:file .kp -destkeystore .keystore -srckeystore mike_ike.p12 -srcstoretype PKCS12 -srcstorepass:file .kp -alias tomcat
文件“.keystore”不存在。我假设keytool将创建它我已经解决了这个问题。我用我的密码“password”在JDK中更新cacerts密钥库,而cacerts密钥库的默认密码是“changeit”好的,所以我有一个答案 1:我的密码中有一个非ASCII字符。openssl可以处理这个问题,keypass不能 2:使用非ASCII密码创建私钥后,我无法使用它,因此我重命名了该文件.kpkey,并使用纯ASCII密码创建了一个新的.kp文件 3:这需要更改为5:C:
openssl pkcs12 -export -in mike_ike_com.cer -inkey mike.privateKey.pass.pem -passin file:.kpkey -out mike_ike.p12 -name tomcat -caname root -chain -CAfile Comodo.root.crt
注意:当它询问“输入导出密码”时,我给它的是来自.kp的pw,而不是来自.kpkey的pw。唯一的更改是-passin文件:.kpkey
如果您使用
-passin file:.kp
作为密码,您可能还想尝试提供该密码:-):现在您正在执行-srcstorepass:file.kp
我不理解您的评论:-(我使用openssl创建了cacerts密钥库,当它要求输入导出密码时,我可以设置密码:这部分工作正常,我只有字母数字字符,但仍然出现错误。导出了一个只有字母字符的新密钥库,keytool工作了?!
openssl pkcs12 -export -in mike_ike_com.cer -inkey mike.privateKey.pass.pem -passin file:.kpkey -out mike_ike.p12 -name tomcat -caname root -chain -CAfile Comodo.root.crt