开发者

What is the sender in RemoteCertificateValidationCallback?

开发者 https://www.devze.com 2023-01-15 00:29 出处:网络
ServicePointManager.ServerCertificateValidationCallback is a property of type RemoteCertificateValidationCallback.The constructor for RemoteCertificateValidationCallback takes a delegate such as

ServicePointManager.ServerCertificateValidationCallback is a property of type RemoteCertificateValidationCallback. The constructor for RemoteCertificateValidationCallback takes a delegate such as

public bool SomeCertificateErrorHandler(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors ss开发者_Go百科lPolicyErrors)
{
    return false; // Don't accept any certificates!
}

When this delegate is called, what specific type is sender? If it isn't obvious from that answer, what use is sender in this delegate?

(Just so there is no confusion, I was being facetious regarding the contents of the method. I'm interested in the parameters.)


Per MSDN (emphasis added):

When doing custom validation, the sender parameter passed to the RemoteCertificateValidationCallback can be a host string name or an object derived from WebRequest (HttpWebRequest, for example) depending on the CertificatePolicy property.

For example, the sender's RequestUri.Host could be validated against a list of host names.

0

精彩评论

暂无评论...
验证码 换一张
取 消