Ejemplo n.º 1
0
        static bool ServiceCertificateValidator(object sender, X509Certificate cert, X509Chain chain,
            System.Net.Security.SslPolicyErrors error)
        {
            X509Certificate2 x509Cert = cert as X509Certificate2;

            CustomTextTraceSource ts = new CustomTextTraceSource("ClientTest.Program.ServiceCertificateValidator",
              "MyTraceSource", SourceLevels.Information);
            
            ts.TraceInformation("Subject Name: " + x509Cert.SubjectName.Name);
            ts.TraceInformation("error: " + error.ToString());

            // Check if there were any errors
            if (error == System.Net.Security.SslPolicyErrors.None)
            {
                return true;
            }
           
            return ValidateCertificate(x509Cert);
        }