openssl - 当我在生成 PFX 文件时不包含 .cert 文件的所有层次结构时会发生什么
问题描述
Ì 我正在尝试 a) 从可用的证书文件和私有文件中导出 PFX 文件,当我使用如下所示的所有可用证书层次结构导出时 - 我收到以下错误
pkcs12 -export -out C:\Users\YSW\SCI\prp\preproduction-abc.com.pfx
-inkey C:\Users\YSW\PCI\prp\pk.preproduction-abc.com.txt -in C:\Users\YSW\SCI\prp\pk.preproduction-abc.com.txt
-in C:\Users\YSW\PCI\prp\TrustedSecureCertificateAuthority5.crt
-in C:\Users\YSW\PCI\prp\USERTrustRSAAddTrustCA.crt
-in C:\Users\YSW\PCI\prp\AddTrustExternalCARoot.crt
错误 ""没有证书匹配私钥,pkcs12 中的错误""
b)当我删除层次结构中的证书并只保留主证书时,如下所示,它对我来说很好,没有任何错误
pkcs12 -export -out C:\Users\YSW\SCI\prp\preproduction-abc.com.pfx
-inkey C:\Users\YSW\PCI\prp\pk.preproduction-abc.com.txt -in C:\Users\YSW\SCI\prp\pk.preproduction-abc.com.txt
在我将此 PFX 文件上传到服务器之前,我想确保在生成 PFX 文件时排除层次结构中的其他证书是否可以
请注意,当我在证书中看到它时,我已经在层次结构中给出了证书,首先是层次结构中最低的,最后是层次结构中最高的
""-在 C:\Users\YSW\SCI\prp\pk.preproduction-abc.com.txt -在 C:\Users\YSW\PCI\prp\TrustedSecureCertificateAuthority5.crt -在 C:\Users\YSW\PCI \prp\USERTrustRSAAddTrustCA.crt -在 C:\Users\YSW\PCI\prp\AddTrustExternalCARoot.crt""
我想知道如果我继续使用从主证书导出的 PFX 会发生什么,或者让我知道如何克服 No certificate matches the Private Key 错误的问题
解决方案
openssl pkcs12 命令只允许“-in”参数使用 1 个参数。因此多次指定它,它只会采用唯一的最后一个参数,这就是您收到错误消息的原因。
通常如果只想添加一个中间证书,您还可以指定“-certfile”参数以在 PFX 文件中再添加一个证书。由于您要添加多个额外的证书,因此最好的方法是将所有证书合并到一个文件中。
所有这些文件都应该是文本文件,所以我会将所有这些文件合并到一个文件中,并将它们作为一个“-in”参数传递。
例如(对于窗户)
copy pk.preproduction-abc.com.txt+TrustedSecureCertificateAuthority5.crt+USERTrustRSAAddTrustCA.crt+AddTrustExternalCARoot.crt allcertificates.pem
(对于 Linux)
cat pk.preproduction-abc.com.txt TrustedSecureCertificateAuthority5.crt USERTrustRSAAddTrustCA.crt AddTrustExternalCARoot.crt > allcertificates.pem
然后将 allcertificates.pem 转换为 pfx:
openssl pkcs12 -export -in allcertificates.pem -out preproduction-abc.com.pfx
推荐阅读
- c# - 从 mysql DB 检索数据时 C# wpf 应用程序关闭
- ios - 在 Obj-c 中使用 truncatingRemainder() 方法
- django - 在 ViewSet 上使用“as_view”方法检索视图时未传递动作装饰器 kwargs
- java - What is "primitive interface method" in Java?
- xml - 如何在 XSLT 中对节点及其以下兄弟节点进行排序?
- c# - 如何更改 wcf 客户端中的时间戳安全标头?
- javascript - 通过 jQuery AJAX 发送文件上传请求时出现问题
- javascript - 如何为javascript中的每个对象进行ajax调用
- reactjs - 如何知道 Ant-Design 表单中的所有字段何时被验证(添加值)?
- java - 根据动态输入提取列表的一部分