开发者

What is the sender in RemoteCertificateValidationCallback?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜