Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UnmanagedCertificateContext.cs
Go to the documentation of this file.
1
using
System.Net.Security
;
2
using
System.Security.Cryptography.X509Certificates
;
3
4
namespace
System.Net
;
5
6
internal
static
class
UnmanagedCertificateContext
7
{
8
internal
static
X509Certificate2Collection
GetRemoteCertificatesFromStoreContext
(
SafeFreeCertContext
certContext)
9
{
10
if
(certContext.
IsInvalid
)
11
{
12
return
new
X509Certificate2Collection
();
13
}
14
return
GetRemoteCertificatesFromStoreContext
(certContext.
DangerousGetHandle
());
15
}
16
17
internal
unsafe
static
X509Certificate2Collection
GetRemoteCertificatesFromStoreContext
(
IntPtr
certContext)
18
{
19
X509Certificate2Collection
x509Certificate2Collection =
new
X509Certificate2Collection
();
20
if
(certContext ==
IntPtr
.
Zero
)
21
{
22
return
x509Certificate2Collection;
23
}
24
global::Interop.Crypt32.CERT_CONTEXT cERT_CONTEXT = *(global::Interop.Crypt32.CERT_CONTEXT*)(
void
*)certContext;
25
if
(cERT_CONTEXT.hCertStore !=
IntPtr
.
Zero
)
26
{
27
global::Interop.Crypt32.CERT_CONTEXT* pPrevCertContext =
null
;
28
while
(
true
)
29
{
30
global::Interop.Crypt32.CERT_CONTEXT* ptr = global::Interop.Crypt32.CertEnumCertificatesInStore(cERT_CONTEXT.hCertStore, pPrevCertContext);
31
if
(ptr ==
null
)
32
{
33
break
;
34
}
35
X509Certificate2
x509Certificate =
new
X509Certificate2
(
new
IntPtr
(ptr));
36
if
(
System
.
Net
.
NetEventSource
.
Log
.IsEnabled())
37
{
38
System
.
Net
.
NetEventSource
.
Info
(certContext, $
"Adding remote certificate:{x509Certificate}"
,
"GetRemoteCertificatesFromStoreContext"
);
39
}
40
x509Certificate2Collection.
Add
(x509Certificate);
41
pPrevCertContext = ptr;
42
}
43
}
44
return
x509Certificate2Collection;
45
}
46
}
Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid.IsInvalid
override bool IsInvalid
Definition
SafeHandleZeroOrMinusOneIsInvalid.cs:9
System.Net.NetEventSource.Log
static readonly System.Net.NetEventSource Log
Definition
NetEventSource.cs:20
System.Net.NetEventSource.Info
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
Definition
NetEventSource.cs:192
System.Net.NetEventSource
Definition
NetEventSource.cs:12
System.Net.Security.SafeFreeCertContext
Definition
SafeFreeCertContext.cs:6
System.Net.UnmanagedCertificateContext.GetRemoteCertificatesFromStoreContext
static X509Certificate2Collection GetRemoteCertificatesFromStoreContext(SafeFreeCertContext certContext)
Definition
UnmanagedCertificateContext.cs:8
System.Net.UnmanagedCertificateContext.GetRemoteCertificatesFromStoreContext
static unsafe X509Certificate2Collection GetRemoteCertificatesFromStoreContext(IntPtr certContext)
Definition
UnmanagedCertificateContext.cs:17
System.Net.UnmanagedCertificateContext
Definition
UnmanagedCertificateContext.cs:7
System.Runtime.InteropServices.SafeHandle.DangerousGetHandle
IntPtr DangerousGetHandle()
Definition
SafeHandle.cs:47
System.Security.Cryptography.X509Certificates.X509Certificate2Collection.Add
int Add(X509Certificate2 certificate)
Definition
X509Certificate2Collection.cs:45
System.Security.Cryptography.X509Certificates.X509Certificate2Collection
Definition
X509Certificate2Collection.cs:13
System.Security.Cryptography.X509Certificates.X509Certificate2
Definition
X509Certificate2.cs:13
System.Net.Security
Definition
CertificateHelper.cs:4
System.Net
Definition
HttpClientJsonExtensions.cs:8
System.Security.Cryptography.X509Certificates
Definition
CertificateAsn.cs:4
System
Definition
BlockingCollection.cs:8
System.IntPtr.Zero
static readonly IntPtr Zero
Definition
IntPtr.cs:18
System.IntPtr
Definition
IntPtr.cs:14
source
System.Net.Security
System.Net
UnmanagedCertificateContext.cs
Generated by
1.10.0