如何使用.net中的socketshttphandler获取服务器证书信息
我的服务使用 SocketHttpHandler 下载 Web 内容并将其发送回客户端。我也试图传递服务器证书信息。 我知道 SocketsHttpHandler 有一个属性来指定用于验证服务器证书的回调(SslClientAuthenticationOptions.RemoteCertificateValidationCallback),其原型是:
RemoteCertificateValidationCallback(object sender, X509Certificate? certificate,
X509Chain? chain,
SslPolicyErrors sslPolicyErrors)
“sender”是一个 SslStream 对象。
有了上面的签名,我不知道如何将信息传回客户端? 看起来 HttpClientHandler 能够做到这一点,因为它的回调的第一个参数是 HttpRequestMessage。
有没有办法用 SocketsHttpHandler 来实现这个目标?
My service uses SocketHttpHandler to download web contents and sends back to clients. I am trying to pass server certificate information, too.
I know that SocketsHttpHandler has a property to specify a callback for validating a server certificate (SslClientAuthenticationOptions.RemoteCertificateValidationCallback) and its prototype is:
RemoteCertificateValidationCallback(object sender, X509Certificate? certificate,
X509Chain? chain,
SslPolicyErrors sslPolicyErrors)
with 'sender' being an SslStream object.
With the above signature, I couldn't figure out how to pass the information back to the client?
It looks like HttpClientHandler is able to do it, since the first parameter of its callback is HttpRequestMessage.
Is there any way to achieve the goal with SocketsHttpHandler?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论