使用此代码,例如:
private static void OnConnect(IAsyncResult ar)
{
var clientConnection = listener.EndAcceptTcpClient(ar);
listener.BeginAcceptTcpClient(OnConnect, ar.AsyncState);
try
{
// SSL the client
var clientStream = clientConnection.GetStream();
var clientSecureStream = new SslStream(clientStream, false);
clientSecureStream.AuthenticateAsServer(certificate);
...
...
我能够成功建立传入的SSL连接。作为客户端身份验证时,连接到该服务器的客户端会指定目标主机: https://docs.microsoft.com/en-us/dotnet/api/system.net.security.sslstream.authenticateasclient?view=netframework-4.7.2#System_Net_Security_SslStream_AuthenticateAsClient_System_String_
如何在上面的代码中检索此目标主机的值?
我已经研究了SslStream构造函数的RemoteCertificateValidationCallback参数,但是互联网告诉我,此回调仅适用于客户端,而不适用于服务器端(我尝试过此操作,并且targetHost参数始终为空字符串)
我已经在这里和在线搜索过,但是找不到解决方法...
SslServer不能根据目标主机发送不同的数据吗? SslStream是否仅不支持这种情况?我完全错过了一些概念吗?