Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ CopyWithPrivateKey()

static X509Certificate2 System.Security.Cryptography.X509Certificates.RSACertificateExtensions.CopyWithPrivateKey ( this X509Certificate2 certificate,
RSA privateKey )
inlinestatic

Definition at line 18 of file RSACertificateExtensions.cs.

19 {
20 if (certificate == null)
21 {
22 throw new ArgumentNullException("certificate");
23 }
24 if (privateKey == null)
25 {
26 throw new ArgumentNullException("privateKey");
27 }
28 if (certificate.HasPrivateKey)
29 {
31 }
32 using (RSA rSA = certificate.GetRSAPublicKey())
33 {
34 if (rSA == null)
35 {
37 }
38 RSAParameters rSAParameters = rSA.ExportParameters(includePrivateParameters: false);
39 RSAParameters rSAParameters2 = privateKey.ExportParameters(includePrivateParameters: false);
40 if (!rSAParameters.Modulus.ContentsEqual(rSAParameters2.Modulus) || !rSAParameters.Exponent.ContentsEqual(rSAParameters2.Exponent))
41 {
43 }
44 }
45 ICertificatePal pal = certificate.Pal.CopyWithPrivateKey(privateKey);
46 return new X509Certificate2(pal);
47 }
static string Cryptography_Cert_AlreadyHasPrivateKey
Definition SR.cs:40
static string Cryptography_PrivateKey_WrongAlgorithm
Definition SR.cs:86
static string Cryptography_PrivateKey_DoesNotMatch
Definition SR.cs:84
Definition SR.cs:7
ICertificatePal CopyWithPrivateKey(DSA privateKey)

References Internal.Cryptography.ICertificatePal.CopyWithPrivateKey(), System.SR.Cryptography_Cert_AlreadyHasPrivateKey, System.SR.Cryptography_PrivateKey_DoesNotMatch, System.SR.Cryptography_PrivateKey_WrongAlgorithm, System.Security.Cryptography.RSAParameters.Exponent, System.Security.Cryptography.RSA.ExportParameters(), System.Security.Cryptography.X509Certificates.X509Certificate2.HasPrivateKey, System.Security.Cryptography.RSAParameters.Modulus, and System.Security.Cryptography.X509Certificates.X509Certificate2.Pal.