Using TLS 1.2 in . NET Framework 2.0

Asked

Viewed 271 times

2

I’m looking to use TLS 1.2 on a call Webclient in the framework .NET 2.0

It is possible?

try
{
    using (System.Net.WebClient client = new System.Net.WebClient())
    {
        string u = client.UploadString(url, xml);
        return u;
    }
}
catch (Exception ex)
{
    throw ex;
}

1 answer

2


It is not possible, at least directly, only in 4.5 upwards. O . NET 2.0 has not been supported for quite some time and should not be used, it does not receive security updates.

Who knows how to catch the source and adapt for use (but it is not something trivial).

Use and improve the code:

using (var client = new WebClient()) {
    return client.UploadString(url, xml);
}

I put in the Github for future reference.

Much simpler, right? Capturing the exception is only causing problems for the code. Just capture the exception to make something useful. What you’re doing is just spoiling the stack trace.

  • 2

    Who negatively could tell how it is possible to do this in . NET 2.0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.