[Mono-bugs] [Bug 378029] New: System.Net.ServicePointManager. ServerCertificateValidationCallback is unimplemented

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Apr 8 11:51:00 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=378029


           Summary: System.Net.ServicePointManager.ServerCertificateValidati
                    onCallback is unimplemented
           Product: Mono: Class Libraries
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: informatique.internet at fiducial.fr
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


In .net 2.0 the good way to control the trust CertificatePolicy is to use
System.Net.ServicePointManager.ServerCertificateValidationCallback

with the old method (.NET 1.1) you should use this code :
if you want to tell mono to trust all https certificates

System.Net.ServicePointManager.CertificatePolicy = new
TrustAllCertificatePolicy();

with 
public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy
{
    public TrustAllCertificatePolicy() {}
    public bool CheckValidationResult(ServicePoint sp, 
        X509Certificate cert,
        WebRequest req, 
        int problem)
    {
        return true;
    }
}

but in .net 2 this code shows a compiler warning : 
warning CS0618: `System.Net.ServicePointManager.CertificatePolicy' is obsolete:
`Use ServerCertificateValidationCallback instead'

so the good .NET 2 way to achieve this is to use :

ServicePointManager.ServerCertificateValidationCallback = 

 delegate(Object obj, X509Certificate certificate, X509Chain chain,

  SslPolicyErrors errors) { return true; };

but this fails at runtime with :
Unhandled Exception: System.NotImplementedException: The requested feature is
not implemented.
  at System.Net.ServicePointManager.set_ServerCertificateValidationCallback
(System.Net.Security.RemoteCertificateValidationCallback value) [0x00000] in
/home/hubert/mono/mcs/class/System/System.Net/ServicePointManager.cs:211 
  at TestWbs2.MainClass.Main (System.String[] args) [0x00018] in
/home/hubert/Projects/NET2/TestWbs2/TestWbs2/Main.cs:20


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list