mscorlib(4.0.0.0) API with additions
SafeCertContextHandle.cs
1 using Microsoft.Win32.SafeHandles;
4 
6 {
7  internal sealed class SafeCertContextHandle : SafeHandleZeroOrMinusOneIsInvalid
8  {
9  internal static SafeCertContextHandle InvalidHandle => new SafeCertContextHandle(IntPtr.Zero);
10 
11  private SafeCertContextHandle()
12  : base(ownsHandle: true)
13  {
14  }
15 
16  internal SafeCertContextHandle(IntPtr handle)
17  : base(ownsHandle: true)
18  {
19  SetHandle(handle);
20  }
21 
22  [DllImport("crypt32.dll", SetLastError = true)]
23  [SuppressUnmanagedCodeSecurity]
24  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
25  private static extern bool CertFreeCertificateContext(IntPtr pCertContext);
26 
27  protected override bool ReleaseHandle()
28  {
29  return CertFreeCertificateContext(handle);
30  }
31  }
32 }
Definition: __Canon.cs:3
Cer
Specifies a method's behavior when called within a constrained execution region.
Definition: Cer.cs:5
Consistency
Specifies a reliability contract.
Definition: Consistency.cs:5