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

◆ CopyWithPrivateKey()

static X509Certificate2 System.Security.Cryptography.X509Certificates.ECDsaCertificateExtensions.CopyWithPrivateKey ( this X509Certificate2 certificate,
ECDsa privateKey )
inlinestatic

Definition at line 18 of file ECDsaCertificateExtensions.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 (ECDsa eCDsa = certificate.GetECDsaPublicKey())
33 {
34 if (eCDsa == null)
35 {
37 }
38 if (!Internal.Cryptography.Helpers.AreSamePublicECParameters(eCDsa.ExportParameters(includePrivateParameters: false), privateKey.ExportParameters(includePrivateParameters: false)))
39 {
41 }
42 }
43 ICertificatePal pal = certificate.Pal.CopyWithPrivateKey(privateKey);
44 return new X509Certificate2(pal);
45 }
static bool AreSamePublicECParameters(ECParameters aParameters, ECParameters bParameters)
Definition Helpers.cs:194
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.Helpers.AreSamePublicECParameters(), Internal.Cryptography.ICertificatePal.CopyWithPrivateKey(), System.SR.Cryptography_Cert_AlreadyHasPrivateKey, System.SR.Cryptography_PrivateKey_DoesNotMatch, System.SR.Cryptography_PrivateKey_WrongAlgorithm, System.Security.Cryptography.ECDsa.ExportParameters(), System.Security.Cryptography.X509Certificates.X509Certificate2.HasPrivateKey, and System.Security.Cryptography.X509Certificates.X509Certificate2.Pal.