internal static X509Certificate2 GetCertificateFromPEMstring(string publicCert, string privateKey) { var certBuffer = GetBytesFromPEM(publicCert, PemStringType.Certificate); var keyBuffer = GetBytesFromPEM(privateKey, PemStringType.RsaPrivateKey); var certificate = new X509Certificate2(certBuffer); var prov = CertificateCrypto.DecodeRsaPrivateKey(keyBuffer); certificate.PrivateKey = prov; return(certificate); }
internal static X509Certificate2 GetCertificateFromPEMstring(string publicCert, string privateKey, string password) { if (string.IsNullOrWhiteSpace(password)) { password = ""; } var certBuffer = GetBytesFromPEM(publicCert, PemStringType.Certificate); var keyBuffer = GetBytesFromPEM(privateKey, PemStringType.RsaPrivateKey); var certificate = new X509Certificate2(certBuffer, password, X509KeyStorageFlags.MachineKeySet); var prov = CertificateCrypto.DecodeRsaPrivateKey(keyBuffer); certificate.PrivateKey = prov; return(certificate); }