public static string ExportPrivateKeyPEM(this X509Certificate2 cert, bool includeB64LineBreaks = true, string headerFooter = defaultPrivKeyHeader) { RSACryptoServiceProvider privKeyPrvdr = (RSACryptoServiceProvider)cert.PrivateKey; return(privKeyPrvdr.ExportPrivateKeyPEM(includeB64LineBreaks, headerFooter)); }