C # server name

As far as I can tell, there is a big limitation in .NET that using C # and .NET it is not possible to connect to a TLS connection that uses Server Name Indicication (SNI). Am I missing something or correctly understood?

Does anyone know if and how I can make an SNI connection using OpenSSL.NET, libcurl.NET, or some other third-party .NET library? Some sample code would be much appreciated.

+4
source share
1 answer

This is a pretty old post, but this answer may help some people, at least it cost me a few days.

.NET Framework . ( 4.5.1, , .NET 4.5+)

:

HttpResponseMessage response;
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, "https://www.google.com");

var handler = new HttpClientHandler
{
    CookieContainer = new CookieContainer()
};
using (var client = new HttpClient(handler))
{
    response = client.SendAsync(httpRequestMessage).Result;
}

GET #. , , , TLS 1.2 SNI. Wireshark , , Client Hello , www.google.com.

, : SNI .NET Framework ( Schannel by Windows, ) URL-, HttpRequestMessage. , URL ( https://www.google.com), RequestUri , SNI - URL- URL. , , .

+1

All Articles