Bug 18256 - System.Net.ServicePointManager not available in PCL.
Summary: System.Net.ServicePointManager not available in PCL.
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-03-07 15:53 UTC by Jon Goldberger [MSFT]
Modified: 2014-03-07 15:57 UTC (History)
2 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Comment 1 Jon Goldberger [MSFT] 2014-03-07 15:54:25 UTC
From case:
I have a data access layer which works fine on iOS and Android but wanted to move it to a PCL. This works as long as I do not need to validate my remote certificate. This is keeping me from breaking the component into the PCL.

Here is some sample code to show you what I mean...

This method uses the ServicePoint manager which is unavailable to PCL.
protected string ExecuteRestGet(string baseUrl, string resourceUrl)

//needed for SSL
System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, cert, chain, errors) => cert.Subject.ToUpper().Contains(_certificateSubject));
ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate);

//ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

var client = new RestClient(baseUrl);

client.AddDefaultHeader("CustomAuthType", "CUSTOMFORMS");
client.AddDefaultHeader("UserName", _userName);
client.AddDefaultHeader("Password", _password);
client.AddDefaultHeader("OSVersion", _osVersion);
client.AddDefaultHeader("AppVersion", _appVersion);
client.AddDefaultHeader("AppType", _appType);
client.AddDefaultHeader("DeviceType", "3");
client.AddDefaultHeader("Content-Type", "application/xml");

var request = new RestRequest();
request.Method = Method.GET;
request.Resource = resourceUrl;
IRestResponse response = client.Execute(request);
string xml = response.Content.ToString();
return xml;


This method just validates the certificate

// callback used to validate the certificate in an SSL conversation
private bool ValidateRemoteCertificate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors policyErrors)
bool result = false;
if (cert.Subject.ToUpper().Contains(_certificateSubject))
result = true;
return result;

Can you tell me how to proceed? Is there a workaround for performing validation like this?

Note You need to log in before you can comment on or make changes to this bug.