예제 #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")));
 }