Skip to content

Instantly share code, notes, and snippets.

@baywet
Created October 4, 2014 00:39
Show Gist options
  • Save baywet/4a25e3b4ee485b30258a to your computer and use it in GitHub Desktop.
Save baywet/4a25e3b4ee485b30258a 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