HTTPS WebGet client with TLS 1.2 and SHA-2 support (.NET Compact Framework)

HTTPS WebGet client with TLS 1.2 and SHA-2 support.

Windows Mobile OS's do not support SHA-2 algorithms which results in inability to validate SHA-2 based certificates so you are unable to connect from these old .NET CF devices. Luckily Rebex HTTPS component solves it by providing custom HttpRequestCreator. This sample demonstrates:

  • Connecting to HTTPS servers (SSL 3.0, TLS 1.0-TLS 1.2 supported) with Rebex HttpRequestCreator.
  • Validating the server certificate (automatic)
  • Using the Rebex HTTPS API to register Rebex HttpRequestCreator.
  • Logging the HTTPS communication to file (various verbose levels available)
  • Fine tuning TLS properties - some slower devices are not able to compute Diffie Hellman on time which results in HTTPS servers closing the connection. Use the DisableDiffieHellman option to workaround it.
  • Sample code

    C#

    // create an instance of Rebex HTTP/HTTPS request creator
    HttpRequestCreator creator = new HttpRequestCreator();
    
    // register the HttpRequestCreator to be used instead of the system implementation
    creator.Register();
    
    // download web page content
    WebRequest request = WebRequest.Create(address);
    WebResponse response = request.GetResponse();
    using (StreamReader sr = new StreamReader(response.GetResponseStream()))
    {
        string body = sr.ReadToEnd();
        tbBody.Text = body;
    }
    response.Close();