You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用OpenSSL从GoDaddy的crt和私钥生成pfx时提示匹配错误

问题:生成PFX文件时提示“No certificate matches private key”但模数匹配

尝试使用OpenSSL从CRT文件和私钥生成PFX文件,持续收到错误:No certificate matches private key。

执行的命令:

openssl pkcs12 -export -out myaudiservice.com.pfx -inkey myaudiservice.com.key -in myaudiservice.com.crt -in gd_bundle-g2-g1.crt

得到的错误:

No certificate matches private key

已尝试的操作:

  • 删除所有相关文件(密钥、CRT证书、证书链),重新生成CSR:
openssl req -new -newkey rsa:2048 -nodes -keyout myaudiservice.com.key -out myaudiservice.com.csr
  • 上传新CSR至GoDaddy重签证书,下载新CRT后用新密钥重试,错误依旧。
  • 验证模数匹配:
mjb@bohr:~/Downloads/myaudiservice.com$ openssl x509 -noout -modulus -in myaudiservice.com.crt | openssl md5
(stdin)= 36d37e4f8f8672c127178a4a9cf32b89
mjb@bohr:~/Downloads/myaudiservice.com$ openssl rsa -noout -modulus -in myaudiservice.com.key | openssl md5
(stdin)= 36d37e4f8f8672c127178a4a9cf32b89

解决步骤

1. 规范证书链传入方式

避免使用多个-in参数,改用-certfile指定证书链文件,主证书单独用-in传入:

openssl pkcs12 -export -out myaudiservice.com.pfx -inkey myaudiservice.com.key -in myaudiservice.com.crt -certfile gd_bundle-g2-g1.crt

2. 合并证书为完整链文件

将用户证书和证书链合并成一个文件后再传入:

# 合并证书
cat myaudiservice.com.crt gd_bundle-g2-g1.crt > full_chain.crt
# 生成PFX
openssl pkcs12 -export -out myaudiservice.com.pfx -inkey myaudiservice.com.key -in full_chain.crt

3. 检查证书文件有效性

确保证书文件无多余内容,能被OpenSSL正常解析:

# 检查用户证书
openssl x509 -in myaudiservice.com.crt -text -noout
# 检查证书链中的所有证书
openssl crl2pkcs7 -nocrl -certfile gd_bundle-g2-g1.crt | openssl pkcs7 -print_certs -text -noout

若某份证书无法解析,重新从GoDaddy下载对应证书链。

4. 指定证书别名

添加-name参数指定证书主题别名,避免名称匹配问题:

openssl pkcs12 -export -out myaudiservice.com.pfx -inkey myaudiservice.com.key -in myaudiservice.com.crt -certfile gd_bundle-g2-g1.crt -name "myaudiservice.com"

5. 检查OpenSSL版本

旧版本OpenSSL可能存在PKCS12处理兼容性问题,运行openssl version查看版本,若为1.0.x等老旧版本,升级至1.1.x或3.x版本后重试。


内容的提问来源于stack exchange,提问作者Mark J. Bobak

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 11:16:01