Openssl 如果我不';在生成PFX文件时,t包括所有.cert文件的层次结构

Openssl 如果我不';在生成PFX文件时,t包括所有.cert文件的层次结构,openssl,pfx,Openssl,Pfx,Ì我试图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-在C:\Users\YSW\SCI\prp\pk.preproduction-abc.com.txt中 -在C:\Users\YSW\PCI

Ì我试图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-在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中

错误 “”没有与私钥匹配的证书, 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-在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,或者让我知道如何克服没有证书匹配私钥错误的问题,

参数“-in”只允许1个参数。所以多次指定它,它只会接受最后一个参数,这就是为什么您会收到错误消息

通常,如果只想添加一个中间证书,您还可以指定“-certfile”参数,将一个以上的证书添加到PFX文件中。因为您想添加多个额外的证书,所以最好的方法是将所有证书合并到一个文件中

所有这些文件都应该是文本文件,所以我会将所有这些文件合并成一个文件,并将它们作为一个“-in”参数传递到中

e、 g.(适用于窗户)

(适用于linux)

然后将allcertificates.pem转换为pfx:

openssl pkcs12 -export -in allcertificates.pem -out preproduction-abc.com.pfx
cat pk.preproduction-abc.com.txt TrustedSecureCertificateAuthority5.crt USERTrustRSAAddTrustCA.crt AddTrustExternalCARoot.crt > allcertificates.pem
openssl pkcs12 -export -in allcertificates.pem -out preproduction-abc.com.pfx