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

◆ GetRemoteCertificate() [2/3]

static X509Certificate2 System.Net.CertificateValidationPal.GetRemoteCertificate ( SafeDeleteContext securityContext,
bool retrieveCollection,
out X509Certificate2Collection remoteCertificateCollection )
inlinestaticprivate

Definition at line 84 of file CertificateValidationPal.cs.

85 {
86 remoteCertificateCollection = null;
87 if (securityContext == null)
88 {
89 return null;
90 }
91 X509Certificate2 x509Certificate = null;
92 SafeFreeCertContext safeFreeCertContext = null;
93 try
94 {
95 safeFreeCertContext = SSPIWrapper.QueryContextAttributes_SECPKG_ATTR_REMOTE_CERT_CONTEXT(GlobalSSPI.SSPISecureChannel, securityContext);
96 if (safeFreeCertContext != null && !safeFreeCertContext.IsInvalid)
97 {
98 x509Certificate = new X509Certificate2(safeFreeCertContext.DangerousGetHandle());
99 }
100 }
101 finally
102 {
103 if (safeFreeCertContext != null && !safeFreeCertContext.IsInvalid)
104 {
105 if (retrieveCollection)
106 {
107 remoteCertificateCollection = UnmanagedCertificateContext.GetRemoteCertificatesFromStoreContext(safeFreeCertContext);
108 }
109 safeFreeCertContext.Dispose();
110 }
111 }
112 if (System.Net.NetEventSource.Log.IsEnabled())
113 {
114 System.Net.NetEventSource.Log.RemoteCertificate(x509Certificate);
115 }
116 return x509Certificate;
117 }
static readonly System.Net.NetEventSource Log

References System.Runtime.InteropServices.SafeHandle.DangerousGetHandle(), System.Runtime.InteropServices.SafeHandle.Dispose(), System.Net.UnmanagedCertificateContext.GetRemoteCertificatesFromStoreContext(), Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid.IsInvalid, System.Net.NetEventSource.Log, System.Net.SSPIWrapper.QueryContextAttributes_SECPKG_ATTR_REMOTE_CERT_CONTEXT(), and System.Net.GlobalSSPI.SSPISecureChannel.