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 ()
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)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 18256 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

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?