Skip to content

Instantly share code, notes, and snippets.

@scrooby
Created November 25, 2016 09:35
Show Gist options
  • Save scrooby/4415bc108858d7a70d5f2e5c010011dc to your computer and use it in GitHub Desktop.
Save scrooby/4415bc108858d7a70d5f2e5c010011dc to your computer and use it in GitHub Desktop.
Write a X509Certificate public key in PEM format
var cert = Org.BouncyCastle.Security.DotNetUtilities.FromX509Certificate(x509certificate);
using (var stringWriter = new StringWriter())
{
var pemWriter = new Org.BouncyCastle.OpenSsl.PemWriter(stringWriter);
pemWriter.WriteObject(cert.GetPublicKey());
var pem = stringWriter.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment