certificate - 使用KeyTool命令将PKCS7(链式证书)导入JKS

标签 certificate keytool pkcs#7 jks

我有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):
  • 将其包含的所有证书打印到PEM文件中OpenSSL> pkcs7 -in initial_file.p7b -inform DER -print_certs -outform PEM -out certs_chain.pem
  • 使用编辑器打开新的PEM文件( certs_chain.pem ),并删除-----BEGIN CERTIFICATE----------END CERTIFICATE-----边界之外的所有内容(仅保留边界内的编码内容,证书本身)并保存。

  • 现在,使用 certs_chain.pem 作为cert_file,keytool应该不会出现导入证书的问题。

    关于certificate - 使用KeyTool命令将PKCS7(链式证书)导入JKS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15814569/

    相关文章:

    java - 丢失 keystore 密码,我有什么选择?

    php - 如何在 web 服务器上的 php 中运行 keytool 和 jarasigner

    openssl - 如何查看 PKCS 7 文件中签署了哪些属性?

    ssl - Sonos - 证书 - letsencrypt

    Delphi - TWebBrowser 中的证书错误,IE9 中没有错误

    linux - keytool 错误 : java. io.IOException:非法 header :-----BEGIN CERTIFICATE-----

    go - 如何复制openssl命令解密cms文件

    java - 将消息和签名转换为 BouncyCaSTLe CMSSignedData 对象

    internet-explorer - 即 : Choosing a digital certificate from a blank list every first visit to my website

    Java Applet Windows-MY keystore PrivateKey getEncoded 为 null