Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PFX/PKCS12 to SNK conversion for mono
- `sn -pc key.pfx key.snk`
- 'Failed to extract public key for key pair -- Keyset does not exist'.
- `sn -p key.pfx key.snk`
- 'key.snk is missing private key needed for signing'.
- // libs used
- using System.Security.Cryptography;
- using System.Security.Cryptography.X509Certificates;
- using Mono.Security;
- //code needs to be put in a method
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement