private int TestVerifyCert() { Certificate c = null; CertificateChain cc = null; try { c = CertificateStore.CreateFromPfxFile(@"certs\server.pfx", "test").FindCertificateByUsage(new string[] { "1.3.6.1.5.5.7.3.1" }); cc = c.GetCertificateChain(); } catch { AddWarning("CC-W-TBC2"); return(0); } try { if (cc.VerifyChain("Mentalis.org Team", AuthType.Server, VerificationFlags.AllowUnknownCA) != CertificateStatus.ValidCertificate) { AddError("CC-TVC1"); } } catch { AddError("CC-TVC2"); } try { if (cc.VerifyChain("Mentalis.org Team", AuthType.Server) != CertificateStatus.UntrustedRoot) { AddError("CC-TVC3"); } } catch { AddError("CC-TVC4"); } try { if (cc.VerifyChain("Other Name", AuthType.Server, VerificationFlags.AllowUnknownCA) != CertificateStatus.NoCNMatch) { AddError("CC-TVC5"); } } catch { AddError("CC-TVC6"); } try { c = CertificateStore.CreateFromCerFile(@"certs\expired.cer").FindCertificateByUsage(new string[] { "1.3.6.1.5.5.7.3.1" }); cc = c.GetCertificateChain(); } catch { AddWarning("CC-W-TBC3"); return(0); } try { IAsyncResult ret = cc.BeginVerifyChain("Mentalis.org Team", AuthType.Server, VerificationFlags.AllowUnknownCA, null, null); ret.AsyncWaitHandle.WaitOne(); if (cc.EndVerifyChain(ret) != CertificateStatus.Expired) { AddError("CC-TVC7"); } } catch { AddError("CC-TVC8"); } return(8); }