コード例 #1
0
            static bool CertificateValidationCallback(
                object sender,
                X509Certificate?certificate,
                X509Chain?chain,
                SslPolicyErrors sslPolicyErrors)
            {
                Assert.NotNull(certificate);

                using (SafeCertContextHandle ctx = new SafeCertContextHandle(certificate.Handle, ownsHandle: false))
                {
                    bool hasStapledOcsp =
                        ctx.CertHasProperty(Interop.Crypt32.CertContextPropId.CERT_OCSP_RESPONSE_PROP_ID);

                    if (((SslStream)sender).CheckCertRevocationStatus)
                    {
                        Assert.True(hasStapledOcsp, "Cert has stapled OCSP data");
                    }
                    else
                    {
                        Assert.False(hasStapledOcsp, "Cert has stapled OCSP data");
                    }
                }

                return(true);
            }