With this code, for example:
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);
...
...
I'm able to successfully establish an incoming SSL connection. The client that is connecting to this server specifies a target host when authenticating as a client: https://learn.microsoft.com/en-us/dotnet/api/system.net.security.sslstream.authenticateasclient?view=netframework-4.7.2#System_Net_Security_SslStream_AuthenticateAsClient_System_String_
How do I retrieve the value of this target host in my code above?
I've looked into the RemoteCertificateValidationCallback parameter for the SslStream constructor, but the internet is telling me that this callback is only meant for client side, and not server side (I tried it and the targetHost argument is always an empty string).
I've searched here and online and I'm having trouble finding a solution...
Should an SslServer not be able to send different data depending on the target host? Does SslStream just not support this scenario? Am I missing some concept completely?