private void verifyLevel2Authentication(SecureSocket socket, Certificate cert, CertificateChain chain, VerifyEventArgs e ) { // Verify level 1 first verifyLevel1Authentication(socket, cert, chain, e); if (!e.Valid) { return; } CertificateStatus certStatus = chain.VerifyChain(null, AuthType.Client, VerificationFlags.IgnoreInvalidName); if (certStatus != CertificateStatus.ValidCertificate) { if ((Adk.Debug & AdkDebugFlags.Messaging_Detailed) != 0) { log.Warn ("Client Certificate is not trusted and fails SIF Level 2 Authentication: " + certStatus.ToString()); } e.Valid = false; } else { e.Valid = true; } }
static void Main(string[] args) { Console.WriteLine("This example shows how you can validate a certificate."); // load the certificate from a file Certificate cert = Certificate.CreateFromCerFile(@"client.cer"); // build a certificate chain CertificateChain cc = new CertificateChain(cert); // validate the chain CertificateStatus status = cc.VerifyChain(null, AuthType.Client); // interpret the result if (status == CertificateStatus.ValidCertificate) { Console.WriteLine("The certificate is valid."); } else { Console.WriteLine("The certificate is not valid [" + status.ToString() + "]."); } }