Example #1
0
 /// <summary>
 ///     Gets a <see cref="SafeCTLHandleContext" /> for the X509 certificate revocation list. The caller of this
 ///     method owns the returned safe handle, and should dispose of it when they no longer need it.
 ///     This handle can be used independently of the lifetime of the original X509 certificate revocation list.
 /// </summary>
 /// <returns>Safe handle to a current CTL instance.</returns>
 /// <permission cref="SecurityPermission">
 ///     The immediate caller must have SecurityPermission/UnmanagedCode to use this method
 /// </permission>
 public void GetSafeContext()
 {
     if (Handle.IsInvalid || Handle.IsClosed)
     {
         Handle = Crypt32.CertCreateCTLContext(65537, RawData, (UInt32)RawData.Length);
         GC.KeepAlive(this);
     }
 }
Example #2
0
 void get_handle(Byte[] rawData)
 {
     Handle = Crypt32.CertCreateCTLContext(65537, rawData, (UInt32)rawData.Length);
     if (Handle.Equals(IntPtr.Zero))
     {
         throw new Exception("Unable to retieve context. The data is invalid.");
     }
 }
Example #3
0
 /// <summary>
 ///     Gets a <see cref="SafeCTLHandleContext" /> for the X509 certificate revocation list. The caller of this
 ///     method owns the returned safe handle, and should dispose of it when they no longer need it.
 ///     This handle can be used independently of the lifetime of the original X509 certificate revocation list.
 /// </summary>
 /// <returns>Safe handle to a current CTL instance.</returns>
 /// <permission cref="SecurityPermission">
 ///     The immediate caller must have SecurityPermission/UnmanagedCode to use this method
 /// </permission>
 public SafeCTLHandleContext GetSafeContext()
 {
     if (ctx == null || ctx.IsInvalid || ctx.IsClosed)
     {
         ctx = Crypt32.CertCreateCTLContext(65537, RawData, (UInt32)RawData.Length);
         GC.KeepAlive(this);
         return(ctx);
     }
     return(ctx);
 }