Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SafeCertContextHandle.cs
Go to the documentation of this file.
1using System;
2
4
5internal class SafeCertContextHandle : SafePointerHandle<SafeCertContextHandle>
6{
8
9 public unsafe CERT_CONTEXT* CertContext => (CERT_CONTEXT*)(void*)handle;
10
11 public bool HasPersistedPrivateKey => CertHasProperty(CertContextPropId.CERT_KEY_PROV_INFO_PROP_ID);
12
13 public bool HasEphemeralPrivateKey => CertHasProperty(CertContextPropId.CERT_KEY_CONTEXT_PROP_ID);
14
16 {
17 get
18 {
20 {
22 }
23 return true;
24 }
25 }
26
28 {
29 }
30
32 {
33 if (parent == null)
34 {
35 throw new ArgumentNullException("parent");
36 }
37 bool success = false;
38 parent.DangerousAddRef(ref success);
39 _parent = parent;
40 SetHandle(_parent.handle);
41 }
42
43 internal new void SetHandle(IntPtr handle)
44 {
45 base.SetHandle(handle);
46 }
47
48 protected override bool ReleaseHandle()
49 {
50 if (_parent != null)
51 {
52 _parent.DangerousRelease();
53 _parent = null;
54 }
55 else
56 {
57 global::Interop.Crypt32.CertFreeCertificateContext(handle);
58 }
60 return true;
61 }
62
63 public unsafe CERT_CONTEXT* Disconnect()
64 {
65 CERT_CONTEXT* result = (CERT_CONTEXT*)(void*)handle;
67 return result;
68 }
69
71 {
72 return global::Interop.crypt32.CertDuplicateCertificateContext(handle);
73 }
74
75 private bool CertHasProperty(CertContextPropId propertyId)
76 {
77 int pcbData = 0;
78 return global::Interop.crypt32.CertGetCertificateContextProperty(this, propertyId, null, ref pcbData);
79 }
80}
static readonly IntPtr Zero
Definition IntPtr.cs:18