Exemple #1
0
 /// <summary>
 /// Returns the trusted state of the specified certificate
 /// </summary>
 /// <param name="cert"></param>
 /// <param name="error"></param>
 /// <returns></returns>
 public bool Verify(X509Certificate cert, out string error)
 {
     using (X509StoreContext ctx = new X509StoreContext())
     {
         ctx.Init(this, cert, this.untrusted);
         if (ctx.Verify())
         {
             error = "";
             return(true);
         }
         error = ctx.ErrorString;
     }
     return(false);
 }
Exemple #2
0
 internal int OnVerifyCertThunk(int ok, IntPtr store_ctx)
 {
     X509StoreContext ctx = new X509StoreContext(store_ctx, false);
     X509Certificate cert = ctx.CurrentCert;
     int depth = ctx.ErrorDepth;
     VerifyResult result = (VerifyResult)ctx.Error;
     // build the X509Chain from the store
     X509Store store = ctx.Store;
     Core.Stack<X509Object> objStack = store.Objects;
     X509Chain chain = new X509Chain();
     foreach (X509Object obj in objStack)
     {
         X509Certificate objCert = obj.Certificate;
         if (objCert != null)
         {
             chain.Add(objCert);
         }
     }
     // Call the managed delegate
     if (OnVerifyCert(this, cert, chain, depth, result))
     {
         return 1;
     }
     else
     {
         return 0;
     }
 }
Exemple #3
0
		private int OnVerifyCertThunk(int ok, IntPtr store)
		{
			var ctx = new X509StoreContext(store, false);

			// build the X509Chain from the store
			using (var chain = new X509Chain())
			{
				foreach (var obj in ctx.Store.Objects)
				{
					var cert = obj.Certificate;
					if (cert != null)
						chain.Add(cert);
				}

				// Call the managed delegate
				return OnVerifyCert(
					this, 
					ctx.CurrentCert, 
					chain, 
					ctx.ErrorDepth, 
					(VerifyResult)ctx.Error
				) ? 1 : 0;
			}
		}
Exemple #4
0
		/// <summary>
		/// Returns the trusted state of the specified certificate
		/// </summary>
		/// <param name="cert"></param>
		/// <param name="error"></param>
		/// <returns></returns>
		public bool Verify(X509Certificate cert, out string error)
		{
			using (X509StoreContext ctx = new X509StoreContext())
			{
				ctx.Init(this, cert, this.untrusted);
				if (ctx.Verify())
				{
					error = "";
					return true;
				}
				error = ctx.ErrorString;
			}
			return false;
		}
Exemple #5
0
            internal int OnVerifyCertThunk(int ok, IntPtr store_ctx)
            {
                var ctx = new X509StoreContext(store_ctx, false);
                X509Certificate cert = ctx.CurrentCert;
                int depth = ctx.ErrorDepth;
                var result = (VerifyResult) ctx.Error;
                // build the X509Chain from the store
                var store = ctx.Store;
                var objStack = store.Objects;
                var chain = new X509Chain();

                foreach (var objCert in objStack.Select(obj => obj.Certificate).Where(objCert => objCert != null))
                {
                    chain.Add(objCert);
                }
                // Call the managed delegate
                return OnVerifyCert(this, cert, chain, depth, result) ? 1 : 0;
            }