Skip to content

Instantly share code, notes, and snippets.

@domgreen
Created May 24, 2011 13:22
Show Gist options
  • Save domgreen/988684 to your computer and use it in GitHub Desktop.
Save domgreen/988684 to your computer and use it in GitHub Desktop.
Method to convert cer to pfx cert
public static void CreatePfxCertFromCerCertAt(string cerLocation, string withPassword)
{
var directory = Path.GetDirectoryName(cerLocation);
var fileName = Path.GetFileNameWithoutExtension(cerLocation);
X509Certificate cert = new X509Certificate(cerLocation);
byte[] certData = cert.Export(X509ContentType.Pkcs12, withPassword);
System.IO.File.WriteAllBytes(directory + @"\" + fileName + ".pfx", certData);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment