Imported Upstream version 6.0.0.293

Former-commit-id: c73c6d59ea27405c8ec2975fc933d2a9a447e603
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-06-08 08:45:03 +00:00
parent 7de0679779
commit 76c6505a64
70 changed files with 132 additions and 69 deletions

View File

@ -30,7 +30,7 @@ namespace System.Security.Cryptography.X509Certificates
{
public static class RSACertificateExtensions
{
public static RSA GetRSAPrivateKey(this X509Certificate2 certificate)
public static RSA GetRSAPrivateKey (this X509Certificate2 certificate)
{
if (certificate == null)
throw new ArgumentNullException (nameof (certificate));
@ -41,11 +41,21 @@ namespace System.Security.Cryptography.X509Certificates
return certificate.Impl.GetRSAPrivateKey ();
}
public static RSA GetRSAPublicKey(this X509Certificate2 certificate)
public static RSA GetRSAPublicKey (this X509Certificate2 certificate)
{
if (certificate == null)
throw new ArgumentNullException("certificate");
throw new ArgumentNullException (nameof (certificate));
return certificate.PublicKey.Key as RSA;
}
public static X509Certificate2 CopyWithPrivateKey (this X509Certificate2 certificate, RSA privateKey)
{
if (certificate == null)
throw new ArgumentNullException (nameof (certificate));
if (privateKey == null)
throw new ArgumentNullException (nameof (privateKey));
var impl = certificate.Impl.CopyWithPrivateKey (privateKey);
return (X509Certificate2)impl.CreateCertificate ();
}
}
}