Skip to content

Instantly share code, notes, and snippets.

@7u4
Forked from baywet/pfxtosnk.cs
Created February 22, 2019 12:00
Show Gist options
  • Select an option

  • Save 7u4/94127a2d14cf8a4ad142a03a09dde106 to your computer and use it in GitHub Desktop.

Select an option

Save 7u4/94127a2d14cf8a4ad142a03a09dde106 to your computer and use it in GitHub Desktop.
sample on how to convert a pfx to snk visual studio assembly signing certificate
X509Certificate2 cert = new X509Certificate2(@"KEY.pfx", "pfxPassword", X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
RSACryptoServiceProvider provider = (RSACryptoServiceProvider) cert.PrivateKey;
byte[] array = provider.ExportCspBlob(!provider.PublicOnly);
using (FileStream fs = new FileStream("FileName.snk", FileMode.Create, FileAccess.Write))
{
fs.Write(array, 0, array.Length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment