Conversion from cert file to pfx file

不羁的心 提交于 2019-12-22 09:54:05

问题


Is it possible to convert a cert file to a pfx file? I tried importing my cerf file into IE, but it is never shown under the "personal" tab, thus I cannot export there.

I am looking for if there is alternatives available.

FYI, the cerf file is created by using "keytool" and then doing an export to a cert file.


回答1:


This article describes two ways of creating a .pfx file from a .cer file:

  • Maxime Lamure: Create your own .pfx file for ClickOnce

Create your public & private Keys (You will be prompt to define the private key’s password):

makecert.exe -sv MyKey.pvk -n "CN=.NET Ready!!!" MyKey.cer

Create your PFX file from the public and private key

pvk2pfx.exe -pvk MyKey.pvk -spc MyKey.cer -pfx MyPFX.pfx -po toto

Programmaticaly you could do so in C# by writing the byte array directly to a file:

byte[] certificateData = certificate.Export(X509ContentType.Pfx, "YourPassword");
File.WriteAllBytes(@"C:\YourCert.pfx", certificateData);

And generally (if you're using IE 8) you might want to have a look at this answer on SO:

  • How to make IE8 trust a self-signed certificate in 20 irritating steps

Hope that helps you.



来源:https://stackoverflow.com/questions/4795924/conversion-from-cert-file-to-pfx-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!