Does SslStream use LocalCertificateSelectionCallback when acting as a server?

大兔子大兔子 提交于 2019-12-11 07:48:38

问题


If I create a SslStream instance like this:

secureStream = new SslStream(stream, true, tlsRemoteCallback, tlsLocalCallback);

And then I use one of the AuthenticateAsServer or BeginAuthenticateAsServer methods, is it at all possible for the LocalCertificateSelectionCallback (tlsLocalCallback) to be invoked? And if so, how?

I'm under the impression this isn't possible, because the AuthenticateAsServer method requires an X509Certificate parameter. And if you pass null, then it throws an exception. But I want to be certain since I'm trying to write a socket API for other developers on my team to use.


回答1:


Are you trying to have secureStream pick which certificate it uses to authenticate itself with the client?

I don't think that is possible. Doing some Reflectoring, I see that the delegate ultimate goes to a "m_CertSelectionDelegate" in System.Net.Security.SecureChannel. A quick analysis of this variable seems to indicate that it's only using for verifying a server cert or verifying the cert the client gives to mutually authenticate itself.



来源:https://stackoverflow.com/questions/836398/does-sslstream-use-localcertificateselectioncallback-when-acting-as-a-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!