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

◆ Build() [2/2]

bool System.Security.Cryptography.X509Certificates.X509Chain.Build ( X509Certificate2 certificate,
bool throwOnException )
inlinepackage

Definition at line 106 of file X509Chain.cs.

107 {
108 lock (_syncRoot)
109 {
110 if (certificate == null || certificate.Pal == null)
111 {
113 }
114 if (_chainPolicy != null && _chainPolicy.CustomTrustStore != null)
115 {
116 if (_chainPolicy.TrustMode == X509ChainTrustMode.System && _chainPolicy.CustomTrustStore.Count > 0)
117 {
118 throw new CryptographicException(System.SR.Cryptography_CustomTrustCertsInSystemMode, "TrustMode");
119 }
120 foreach (X509Certificate2 item in _chainPolicy.CustomTrustStore)
121 {
122 if (item == null || item.Handle == IntPtr.Zero)
123 {
124 throw new CryptographicException(System.SR.Cryptography_InvalidTrustCertificate, "CustomTrustStore");
125 }
126 }
127 }
128 Reset();
129 X509ChainPolicy chainPolicy = ChainPolicy;
130 _pal = ChainPal.BuildChain(_useMachineContext, certificate.Pal, chainPolicy._extraStore, chainPolicy._applicationPolicy, chainPolicy._certificatePolicy, chainPolicy.RevocationMode, chainPolicy.RevocationFlag, chainPolicy.CustomTrustStore, chainPolicy.TrustMode, chainPolicy.VerificationTime, chainPolicy.UrlRetrievalTimeout, chainPolicy.DisableCertificateDownloads);
131 if (_pal == null)
132 {
133 return false;
134 }
135 _chainElements = new X509ChainElementCollection(_pal.ChainElements);
136 Exception exception;
137 bool? flag = _pal.Verify(chainPolicy.VerificationFlags, out exception);
138 if (!flag.HasValue)
139 {
140 if (throwOnException)
141 {
142 throw exception;
143 }
144 flag = false;
145 }
146 return flag.Value;
147 }
148 }
static unsafe ChainPal BuildChain(bool useMachineContext, ICertificatePal cert, X509Certificate2Collection extraStore, OidCollection applicationPolicy, OidCollection certificatePolicy, X509RevocationMode revocationMode, X509RevocationFlag revocationFlag, X509Certificate2Collection customTrustStore, X509ChainTrustMode trustMode, DateTime verificationTime, TimeSpan timeout, bool disableAia)
Definition ChainPal.cs:94
static string Cryptography_InvalidTrustCertificate
Definition SR.cs:80
static string Cryptography_CustomTrustCertsInSystemMode
Definition SR.cs:78
static string Cryptography_InvalidContextHandle
Definition SR.cs:70
Definition SR.cs:7
bool? Verify(X509VerificationFlags flags, out Exception exception)
X509ChainElement[] ChainElements
Definition IChainPal.cs:9

References System.Security.Cryptography.X509Certificates.X509ChainPolicy._applicationPolicy, System.Security.Cryptography.X509Certificates.X509ChainPolicy._certificatePolicy, System.Security.Cryptography.X509Certificates.X509Chain._chainElements, System.Security.Cryptography.X509Certificates.X509Chain._chainPolicy, System.Security.Cryptography.X509Certificates.X509ChainPolicy._extraStore, System.Security.Cryptography.X509Certificates.X509Chain._pal, System.Security.Cryptography.X509Certificates.X509Chain._syncRoot, System.Security.Cryptography.X509Certificates.X509Chain._useMachineContext, Internal.Cryptography.Pal.ChainPal.BuildChain(), Internal.Cryptography.Pal.IChainPal.ChainElements, System.Security.Cryptography.X509Certificates.X509Chain.ChainPolicy, System.Collections.CollectionBase.Count, System.SR.Cryptography_CustomTrustCertsInSystemMode, System.SR.Cryptography_InvalidContextHandle, System.SR.Cryptography_InvalidTrustCertificate, System.Security.Cryptography.X509Certificates.X509ChainPolicy.CustomTrustStore, System.Security.Cryptography.X509Certificates.X509ChainPolicy.DisableCertificateDownloads, System.exception, System.item, System.Security.Cryptography.X509Certificates.X509Certificate2.Pal, System.Security.Cryptography.X509Certificates.X509Chain.Reset(), System.Security.Cryptography.X509Certificates.X509ChainPolicy.RevocationFlag, System.Security.Cryptography.X509Certificates.X509ChainPolicy.RevocationMode, System.Security.Cryptography.X509Certificates.X509ChainPolicy.TrustMode, System.Security.Cryptography.X509Certificates.X509ChainPolicy.UrlRetrievalTimeout, System.Security.Cryptography.X509Certificates.X509ChainPolicy.VerificationFlags, System.Security.Cryptography.X509Certificates.X509ChainPolicy.VerificationTime, Internal.Cryptography.Pal.IChainPal.Verify(), and System.IntPtr.Zero.