将 pfx 格式转换为 p12
我需要将 .pfx
格式证书(从 Windows MMC)导出到 .p12
以在另一个应用程序中使用。我找不到办法做到这一点。
任何人都可以建议一个方法吗?
I need to export a .pfx
format certificate (from Windows MMC) to .p12
to use in another application. I cant find a way to do this.
Can anyone suggest a method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
.p12
和.pfx
都是 PKCS #12 文件。我错过了什么吗?您是否尝试过将导出的
.pfx
文件重命名为具有.p12
扩展名?.p12
and.pfx
are both PKCS #12 files. Am I missing something?Have you tried renaming the exported
.pfx
file to have a.p12
extension?我在使用 openconnect 处理 .pfx 文件时遇到了问题。重命名并没有解决问题。我使用 keytool 将其转换为 .p12 并且它有效。
就我而言,新文件 (new.p12) 的密码必须与 .pfx 文件的密码相同。
I had trouble with a .pfx file with openconnect. Renaming didn't solve the problem. I used keytool to convert it to .p12 and it worked.
In my case the password for the new file (new.p12) had to be the same as the password for the .pfx file.
如果您正在寻找带有 UI 的快速手动流程。我总是使用 Mozilla Firefox 从 PFX 转换为 P12。首先将证书导入 Firefox 浏览器(选项 > 隐私和安全 > 查看证书... > 导入...)。安装后,通过从证书管理器中选择证书名称来执行导出以创建 P12 文件,然后单击备份...并输入文件名,然后输入密码。
If you are looking for a quick and manual process with UI. I always use Mozilla Firefox to convert from PFX to P12. First import the certificate into the Firefox browser (Options > Privacy & Security > View Certificates... > Import...). Once installed, perform the export to create the P12 file by choosing the certificate name from the Certificate Manager and then click Backup... and enter the file name and then enter the password.
这更多的是jglouie回应的延续。
如果您使用 openssl 将 PKCS#12 证书转换为公钥/私钥 PEM 密钥,则无需重命名该文件。假设该文件名为 cert.pfx,以下三个命令将创建一个公共 pem 密钥和一个加密的私有 pem 密钥:
前两个命令可能会提示输入导入密码。这将是随 PKCS#12 文件提供的密码。
第三条命令将让您指定证书的加密密码。这是您在使用证书时将输入的内容。
This is more of a continuation of jglouie's response.
If you are using openssl to convert the PKCS#12 certificate to public/private PEM keys, there is no need to rename the file. Assuming the file is called cert.pfx, the following three commands will create a public pem key and an encrypted private pem key:
The first two commands may prompt for an import password. This will be a password that was provided with the PKCS#12 file.
The third command will let you specify the encryption passphrase for the certificate. This is what you will enter when using the certificate.
首先我们有certificate.PFX文件
第1步:(提取私钥)
第2步:(创建P12文件)
first We Have certificate.PFX file
Step1: (Extract Private Key)
Step2: (Create P12 file)
就我而言,我想导入从 Entrust 导出的
.pfx
并将其导入到gpgsm
中。gpgsm
不喜欢 PFX:Paul Chan 的上述答案有效(使用 Firefox),但我想要命令行解决方案。
受到其他答案的启发,我只是尝试使用 openssl pcks12 进行往返,并且它有效:
In my case, I wanted to import a
.pfx
exported from Entrust and import it intogpgsm
.gpgsm
did not like that PFX:Paul Chan's answer above worked (using Firefox), but I wanted a command line solution.
Inspired by the other answers, I simply tried roundtripping it using
openssl pcks12
, and it worked:看来遗留加密算法已在 openssl 中删除,但仍在 gpsm 中使用。这意味着您必须在使用 openssl 转换密钥时显式重新启用它们:
It seems that legacy encryption algorithms have been dropped in openssl which are still used in gpsm. This means that you have to explicitly re-enable them while converting the keys with openssl:
运行此命令将
.cert
文件更改为.p12
:其中
server.key
是服务器密钥,server.cert 是 CA 颁发的证书或自签名证书文件。
Run this command to change
.cert
file to.p12
:Where
server.key
is the server key andserver.cert
is a CA issue cert or a self sign cert file.