C # Using HttpWebRequest to use Tls12 instead of SSLv3

I have an application that uses some web services and acquires data through JSON, everything worked fine for quite some time, until the latest discoveries that SSLv3 were vulnerable to man-in-the-middle attacks and server owners will disconnect SSLv3 forever. In my application, there were problems connecting and returning with the error "The request was aborted: it was not possible to establish a secure SSL / TLS connection." I tried to find a solution and found the information I got to add this code before creating the web request:

        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
        ServicePointManager.ServerCertificateValidationCallback = delegate{ 
                    return true;
        };

Unfortunately, you are out of luck, the application acts the same as before, and I do not know if this code really does anything or if there is still a problem with the server. The error information is rather vague, and I have trouble figuring out where everything goes wrong.

Here is my code

        ...
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.ContentType = GetRequestContentType();
        request.Method = method.ToString();
        request.Credentials = GetCredential(url);
        request.PreAuthenticate = true;
        CookieContainer cookieContainer = new CookieContainer();
        request.CookieContainer = cookieContainer;
        ...

I want to ask how to install Tls12 , which will be used by default, and make sure that in my final request that I make, the required protocol is indicated.

If I confirm that my application is working fine at my end, is there a way to get more detailed information from the server response and pinpoint the cause of the error?

Thanks for all the answers and suggestions.

EDIT

, http://www.telerik.com/download/fiddler, , . , SSL-, , . , , . , . .

+4
1

, (, , , , ), ,

request.Credentials = GetCredential(url);

,

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

, httpwebrequest . SecurityProtocolType Tls12 .

+5

All Articles