示例#1
0
 /// <summary>
 ///     Gets a <see cref="X509Certificate2" /> from a Base64-encoded certificate and private key.
 /// </summary>
 /// <param name="cert"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public static X509Certificate2 GetCertificate(string cert, string key)
 {
     return(GetCertificate(cert)
            .CopyWithPrivateKey
            (
                PemExt.DecodeRsaPrivateKey
                (
                    PemExt.GetBytesFromPem
                    (
                        key,
                        "RSA PRIVATE KEY"
                    )
                )
            ));
 }
示例#2
0
 public static (X509Certificate2, RSA) GetCertificateAndKey(string cert, string key)
 {
     return(GetCertificate(cert), PemExt.DecodeRsaPrivateKey(PemExt.GetBytesFromPem(key, "RSA PRIVATE KEY")));
 }
示例#3
0
 /// <summary>
 ///     Gets a <see cref="X509Certificate2" /> from a Base64-encoded certificate.
 /// </summary>
 /// <param name="cert"></param>
 /// <returns></returns>
 public static X509Certificate2 GetCertificate(string cert)
 {
     return(new X509Certificate2(PemExt.GetBytesFromPem(cert, "CERTIFICATE")));
 }