Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using C# can I make an SSL connection using Server Name Indication (SNI)?

Tags:

c#

ssl

sni

I currently have this code that makes an SSL connection to a server:

using (client = new TcpClient())
{

    client.Connect(Hostname, Port);
    var callback = new RemoteCertificateValidationCallback(ValidateServerCertificate);


    using (stream = new SslStream(client.GetStream(), false, callback))
    {
        stream.AuthenticateAsClient(Hostname);
    }
}

However, I don't think it supports SNI because the wrong certificate is being returned from the SNI configured server. Is there anyway to make the SSL connection using SNI?

I am using .NET 2 (willing to upgrade if necessary). I am using Windows 7, but would like the software to work on other platforms such as Windows 2008 if possible.

like image 502
TonyM Avatar asked Mar 30 '12 15:03

TonyM


1 Answers

So to conclude it seems as if the answer is: No, there is no way that you can make the TLS connection use SNI :-(

I couldn't find any C# example code making a TLS connection with SNI. Theoretically though, it should be possible to create that manually, i.e. as per How to implement Server Name Indication (SNI)

however, an attempt over here failed: TLS SNI with C#

like image 155
Frederick Nord Avatar answered Sep 27 '22 20:09

Frederick Nord