usingSystem.Net.Security;
usingSystem.Security;
usingSystem.Security.Cryptography;
usingSystem.Security.Cryptography.X509Certificates;
privateboolCheckValidationResult(objectsender,
X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
returntrue;// Always accept
}
publicHttpWebResponse getUrlResponse(stringurl)
{
HttpWebResponse resp = null;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
if(url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.ServerCertificateValidationCallback =
newRemoteCertificateValidationCallback(CheckValidationResult);
}
//...
resp = (HttpWebResponse)req.GetResponse();
//...
}