SafeCertContextHandle provides a SafeHandle class for an X509Certificate's certificate context as stored in its System.Security.Cryptography.X509Certificates.X509Certificate.Handle property. This can be used instead of the raw IntPtr to avoid races with the garbage collector, ensuring that the X509Certificate object is not cleaned up from underneath you while you are still using the handle pointer.

This safe handle type represents a native CERT_CONTEXT. (

A SafeCertificateContextHandle for an X509Certificate can be obtained by calling the System.Security.Cryptography.X509Certificates.X509Certificate.GetCertificateContext() extension method.

Permission Requirements:
System.Security.Permissions.SecurityPermission The immediate caller must have SecurityPermission/UnmanagedCode to use this type.

Last edited Jun 3, 2009 at 8:28 PM by shawnfa, version 2


No comments yet.