Error message: 'System.Net.ServicePointManager.CertificatePolicy' is obsolete: 'CertificatePolicy is obsoleted for this type, please use ServerCertificateValidationCallback instead.' http://go.microsoft.com/fwlink/?linkid=14202
ServicePointManager.CertificatePolicy = new CustomCertificatePolicy();
modify to
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback(CertValidation);
bool CertValidation(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslpolicyErrors)
{
bool result = false;
// TODO: implement
return result;
}
for example if you want to accept untrusted server certificate which I don't recommend :D use it like:
bool CertValidation(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslpolicyErrors)
{
bool result = false;
if ((chain != null) && (chain.ChainStatus.Length == 1) &&
(chain.ChainStatus[0].Status == X509ChainStatusFlags.UntrustedRoot))
result = true;
return result?result:sslpolicyErrors == SslPolicyErrors.None;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment