[system] Remove port number from TLS Server Name Identification (SNI). Fixes #46549...
[mono.git] / mcs / class / System / Mono.Net.Security / MonoTlsStream.cs
index 7985ddfb0620d9fdcc934262335ad60c534d5818..ed3e126abde8d4bf59241ecc00ada41d08c8daf7 100644 (file)
@@ -97,8 +97,15 @@ namespace Mono.Net.Security
                        sslStream = provider.CreateSslStream (networkStream, false, settings);
 
                        try {
+                               var host = request.Host;
+                               if (!string.IsNullOrEmpty (host)) {
+                                       var pos = host.IndexOf (':');
+                                       if (pos > 0)
+                                               host = host.Substring (0, pos);
+                               }
+
                                sslStream.AuthenticateAsClient (
-                                       request.Host, request.ClientCertificates,
+                                       host, request.ClientCertificates,
                                        (SslProtocols)ServicePointManager.SecurityProtocol,
                                        ServicePointManager.CheckCertificateRevocationList);