简体   繁体   中英

How do i fix the Could not create SSL/TLS secure channel Error in ASP.NET

I am having an issue trying to deploy a WebApi which makes an outbound Soap call to a Remote System to a IIS Server. I can run my Code on my Workstation with no problems but when i deploy to Server it fails. I even went so far to install visual Studio to my Server and run the code in Studio and it also works fine. No matter from where i deploy the code , from local ore Remote Studio 2019 it always fails on the Server with the following error.

The request was aborted: Could not create SSL/TLS secure channel

Below is the function i call to make the request which causes the error and throws a webexception.

Try
        Dim log As New logger
        Dim aTTADDRVALRESP As ATT_ADDR_VAL_RESP = Nothing
        Dim timeSpan As System.TimeSpan
        Dim now As System.DateTime = System.DateTime.Now
        Dim startTime As System.DateTime = Conversions.ToDate(Now.ToString("HH:mm:ss.fff"))
    Try
                Dim results() As Object = Me.Invoke("submitAddVal", New Object() {ATT_ADDR_VAL_REQ})
                Dim myCodes As XmlHelper.AttResponseCode = New XmlHelper.AttResponseCode()
                myCodes = XmlHelper.GetAttResponseCodes(XmlHelper.DebugXML(results(0)))
                System.Diagnostics.Debug.WriteLine(myCodes.ToString)
                now = System.DateTime.Now
                Dim [date] As System.DateTime = Conversions.ToDate(now.ToString("HH:mm:ss.fff"))
                timeSpan = [date].Subtract(startTime)
                Dim totalMilliseconds As Double = timeSpan.TotalMilliseconds
                aTTADDRVALRESP = DirectCast(results(0), ATT_ADDR_VAL_RESP)


    Catch soapException1 As System.Web.Services.Protocols.SoapException                 
                Dim soapException As System.Web.Services.Protocols.SoapException = soapException1
                log.writeLog("ADDRVAL_SOAPHTTPBinding", "97", SoapException.Detail)
    Catch webException As System.Net.WebException

                Dim ex As System.Net.WebException = webException 
                log.writeLog("ADDRVAL_SOAPHTTPBinding", "108", ex.Message)
    End Try
            Return aTTADDRVALRESP
 Catch ex As Exception
    System.Diagnostics.Debug.WriteLine(ex)
    Dim log As New logger
   log.writeLog("ADDRVAL_SOAPHTTPBinding", "113", ex)
 End Try

So the question, anyone have an idea what would cause this, how to fix or troubleshoot this issue.

After some time digging around we figured out the issue. As my app uses a certificate file to communicate with the remote system it ended up to be the culprit. Even so the File was accessible from code the default pool account did not have enough permission. Originally i gave full read and writes to the everyone group for the file which was not sufficient.The Identity by default is ApplicationPoolIdenty. Once i changed it to LocalSystem it worked so Now i can play around with Account permission knowing that's the source of the issue.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM