我有一个由 Thwate 提供的 p7b 文件。当我尝试使用以下命令导出 cer 文件中的证书时,证书链不包括在内。
请建议如何做到相同效果。导入到 Weblogic 密钥库需要此 CER。
openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer
我有一个由 Thwate 提供的 p7b 文件。当我尝试使用以下命令导出 cer 文件中的证书时,证书链不包括在内。
请建议如何做到相同效果。导入到 Weblogic 密钥库需要此 CER。
openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer
-print_certs是您想要使用的选项,以列出p7b文件中的所有证书,您可能需要指定您正在读取的p7b文件的格式。
然后,您可以将输出重定向到一个新文件中,以构建证书的串联列表。
在文本编辑器中打开该文件,您将看到Base64(PEM)或二进制数据(DER)。
openssl pkcs7 -inform DER -outform PEM -in certificate.p7b -print_certs > certificate_bundle.cer
Change the leader and trailer so the file looks similar to this:
-----BEGIN PKCS7-----
[... certificate content here ...]
-----END PKCS7-----
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
Run the following OpenSSL command (works on Ubuntu 14.04.4, as of this writing):
openssl pkcs7 -print_certs –in pkcs7.p7b -out pem.cer
openssl x509 -outform DER -in certificate.cer | openssl x509 -inform DER -outform PEM
我曾经遇到过从文件中提取证书的类似问题。这可能不是最好的方法,但对我有效。
openssl pkcs7 -inform DER -print_certs -in <path of the file> | awk 'split_after==1{n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1} {print > "cert" n ".pem"}'
openssl pkcs7 -inform DER -in root.p7b -print_certs | awk '/^-+BEG/{n++;s=1}s{print>"root_"n".crt"}/^-+END/{s=0}'