Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CopyWithPrivateKey()

static X509Certificate2 System.Security.Cryptography.X509Certificates.DSACertificateExtensions.CopyWithPrivateKey ( this X509Certificate2 certificate,
DSA privateKey )
inlinestatic

Definition at line 21 of file DSACertificateExtensions.cs.

22 {
23 if (certificate == null)
24 {
25 throw new ArgumentNullException("certificate");
26 }
27 if (privateKey == null)
28 {
29 throw new ArgumentNullException("privateKey");
30 }
31 if (certificate.HasPrivateKey)
32 {
34 }
35 using (DSA dSA = certificate.GetDSAPublicKey())
36 {
37 if (dSA == null)
38 {
40 }
41 DSAParameters dSAParameters = dSA.ExportParameters(includePrivateParameters: false);
42 DSAParameters dSAParameters2 = privateKey.ExportParameters(includePrivateParameters: false);
43 if (!dSAParameters.G.ContentsEqual(dSAParameters2.G) || !dSAParameters.P.ContentsEqual(dSAParameters2.P) || !dSAParameters.Q.ContentsEqual(dSAParameters2.Q) || !dSAParameters.Y.ContentsEqual(dSAParameters2.Y))
44 {
46 }
47 }
48 ICertificatePal pal = certificate.Pal.CopyWithPrivateKey(privateKey);
49 return new X509Certificate2(pal);
50 }
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.DSA.ExportParameters(), System.Security.Cryptography.DSAParameters.G, System.Security.Cryptography.X509Certificates.X509Certificate2.HasPrivateKey, System.Security.Cryptography.DSAParameters.P, System.Security.Cryptography.X509Certificates.X509Certificate2.Pal, System.Security.Cryptography.DSAParameters.Q, and System.Security.Cryptography.DSAParameters.Y.