我有PKCS#7格式的CA颁发的CERT。它内部有证书(链接)。
Keytool无法识别PKCS7格式。我已尝试使用OpenSSL工具将PKCS7格式的证书转换为PEM格式,但失败。我收到错误消息“无法加载PKCS7对象”。
如何将PKCS7证书链导入我的JKS?
最佳答案
您可以在keytool reference中阅读 -importcert 命令:
Reads the certificate or certificate chain (where the latter is supplied in a PKCS#7 formatted reply) from the file cert_file, and stores it in the keystore entry identified by alias. If no file is given, the certificate or PKCS#7 reply is read from stdin.
keytool can import X.509 v1, v2, and v3 certificates, and PKCS#7 formatted certificate chains consisting of certificates of that type.
尝试按原样导入PKCS7证书。
虽然,它并不总是有效。如果遇到问题,请尝试执行以下操作(使用OpenSSL):
OpenSSL> pkcs7 -in initial_file.p7b -inform DER -print_certs -outform PEM -out certs_chain.pem
-----BEGIN CERTIFICATE-----
和-----END CERTIFICATE-----
边界之外的所有内容(仅保留边界内的编码内容,证书本身)并保存。现在,使用 certs_chain.pem 作为
cert_file
,keytool应该不会出现导入证书的问题。
关于certificate - 使用KeyTool命令将PKCS7(链式证书)导入JKS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15814569/