Verify() 공개 메소드

Does not throw on api error. Returns default(bool?) and sets "exception" instead.
public Verify ( X509VerificationFlags flags, Exception &exception ) : bool?
flags X509VerificationFlags
exception System.Exception
리턴 bool?
예제 #1
0
        private static bool VerifyCertificateIgnoringErrors(SafeCertContextHandle pCertContext)
        {
            ChainPal chainPal = ChainPal.BuildChain(
                true,
                CertificatePal.FromHandle(pCertContext.DangerousGetHandle()),
                null, //extraStore
                null, //applicationPolicy
                null, //certificatePolicy
                X509RevocationMode.NoCheck,
                X509RevocationFlag.ExcludeRoot,
                DateTime.Now,
                new TimeSpan(0, 0, 0));

            if (chainPal == null)
            {
                return(false);
            }

            using (chainPal)
            {
                Exception verificationException;
                bool?     verified = chainPal.Verify(X509VerificationFlags.NoFlag, out verificationException);
                if (!(verified.HasValue && verified.Value))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        private static bool VerifyCertificateIgnoringErrors(SafeCertContextHandle pCertContext)
        {
            // This needs to be kept in sync with IsCertValid in the
            // Unix/OpenSSL PAL version (and potentially any other PALs that come about)
            ChainPal chainPal = ChainPal.BuildChain(
                false,
                CertificatePal.FromHandle(pCertContext.DangerousGetHandle()),
                null, //extraStore
                null, //applicationPolicy
                null, //certificatePolicy
                X509RevocationMode.NoCheck,
                X509RevocationFlag.ExcludeRoot,
                null,
                X509ChainTrustMode.System,
                DateTime.Now,
                new TimeSpan(0, 0, 0));

            if (chainPal == null)
            {
                return(false);
            }

            using (chainPal)
            {
                Exception verificationException;
                bool?     verified = chainPal.Verify(X509VerificationFlags.NoFlag, out verificationException);
                if (!verified.GetValueOrDefault())
                {
                    return(false);
                }
            }

            return(true);
        }