/// <summary> /// Designated initializer /// </summary> /// <param name="issue">CertificateIssue</param> /// <param name="cert">X509Certificate</param> /// <param name="request">WebRequest</param> /// <param name="cancel">bool</param> public CertificateIssueCancelEventArgs(CertificateIssue issue, X509Certificate cert, WebRequest request, bool cancel) : base(cancel) { CertificateIssue = issue; Certificate = cert; WebRequest = request; }
// this is marked obsolete by MS in the CLR 2.0 public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest req, int problem) { try { if (problem != 0) { // move bits around to get it casted from an signed int to a normal long enum type: CertificateIssue issue = (CertificateIssue)(((problem << 1) >> 1) + 0x80000000); // this is marked obsolete by MS in the CLR 2.0 // It seems also they has broken the old impl., we don't get a valid cert object now (handle is 0) on WinXP SP2 // via parameter, so we now use that of the servicepoint as a workaround: CertificateIssueCancelEventArgs args = new CertificateIssueCancelEventArgs(issue, sp.Certificate, req, true); AsyncWebRequest.RaiseOnCertificateIssue(sp, args); return(!args.Cancel); } } catch (Exception ex) { Trace.WriteLine("TrustSelectedCertificatePolicy.CheckValidationResult() error: " + ex.Message); } // The 1.1 framework calls this method with a problem of 0, even if nothing is wrong return(problem == 0); }