| File: Microsoft\Win32\SafeHandles\SafeCertContextHandle.cs | Web Access |
| Project: src\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\System.Security.Cryptography.Pkcs.csproj (System.Security.Cryptography.Pkcs) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics; using System.Runtime.InteropServices; using static Interop.Crypt32; namespace Microsoft.Win32.SafeHandles { internal sealed class SafeCertContextHandle : SafeHandle { internal SafeCertContextHandle(IntPtr handle) : base(handle, ownsHandle: true) { } internal unsafe CERT_CONTEXT* DangerousGetCertContext() { return (CERT_CONTEXT*)DangerousGetHandle(); } public sealed override bool IsInvalid { get { return handle == IntPtr.Zero; } } protected sealed override bool ReleaseHandle() { Interop.Crypt32.CertFreeCertificateContext(handle); // CertFreeCertificateContext always returns TRUE so no point in checking. SetHandle(IntPtr.Zero); return true; } } }