HttpsGet

Very simple and very fast HTTPS downloader.

Usage

Console utility that uses TlsStream API to asynchronously download files from HTTPS servers. Supports TLS 1.3 and 1.2 on all .NET Core 3.1 platforms and all Windows platforms with .NET 4.6 or newer.

> HttpsGet https://test.rebex.net/rebex-logo.gif

C#

// Create an instance of Rebex TlsStream to secure the connection with TLS.
// TlsStream expects a connected socket as constructor argument and becomes the owner of the socket.
using (var tlsStream = new TlsStream(socket))
{
    // Only allow TLS 1.3 and TLS 1.2.
    tlsStream.Parameters.Version = TlsVersion.TLS12 | TlsVersion.TLS13;

    // Our instance is the 'client' side of the connection, so call the AuthenticateAsClientAsync method and
    // add the host name as the argument to the method.
    // Host name is needed for TLS SNI (Server Name Indication) extension and for server certificate validation.
    Write("Negotiation TLS session... ");
    await tlsStream.AuthenticateAsClientAsync(url.Host);
    // Connection is now secured with TLS
    WriteLine("OK");
    WriteLine($"Cipher: {tlsStream.Cipher}");

    // Do the rest here
}