none
net Framework and TLS 1.2 RRS feed

  • Question

  • Hi Team,

    we are facing an issue in consuming restful web service using TLS 1.2 protocol and below is the exception we are getting in our code. .net Framework 4.6.1 used to develop the application.

    Exception message : - The request was aborted: Could not create
    SSL/TLS secure channel.

    Event Viewer Logs: -

    A fatal alert was generated and sent to the remote endpoint. This may result in termination of the connection. The TLS protocol defined fatal error code is 40. The Windows SChannel error state is 252.

    Code: -

    public

    asyncTask<string> CallAPI(stringFTWebServiceURL, stringjsonStr)

            {        

    try

                {

               

    Logger.fnLog(FTWebServiceURL, false, "CAll CallAPI Method() start....");

               

    HttpClientclient = newHttpClient();

               

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

                client.BaseAddress =

    newUri(FTWebServiceURL);

                client.DefaultRequestHeaders.Accept.Clear();

                client.DefaultRequestHeaders.Accept.Add(

    newMediaTypeWithQualityHeaderValue("application/json"));

               

    HttpResponseMessageresponseMessage =

                   

    await


                           client.PostAsync(

    newUri(FTWebServiceURL),

                          

    newStringContent(jsonStr));

               

    varcontents = awaitresponseMessage.Content.ReadAsStringAsync();

               

    Logger.fnLog(contents, false, "CAll CallAPI Method() ends....");

               

    returnawaitTask.Run(() => contents);

            }

               

    catch(Exceptionex)

                {

                   

    Logger.fnLog(ex.Message, false, "Catch for CallAPI()");

                   

    returnex.Message;

                }

            }

    Thanks,

    Ravi Sivaji

    Wednesday, September 20, 2017 7:28 AM

All replies

  • Hi Ravi Sivaji,

    Thank you for posting here.

    For your question is more related to web service, you could post a new thread in WCF, ASMX and other Web Services forum for suitable support.

    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework, including Managed Extensibility Framework (MEF), Charting Controls, CardSpace, Windows Identity Foundation (WIF), Point of Sale (POS), Transactions.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, September 21, 2017 1:26 PM