I have shared the standard soap wsdl with the third party. Its being used by them to create records in salesforce. They are using .NET to integrate with Salesforce. We are able to create records using SOAP UI using the credentials shared with them. But when they are using it using their code, they are getting below error

The underlying connection was closed:Could not establish trust relationship

enter image description here

However they are able to get the session Id using the login method. Can anyone help me understand what might be the issue here. They are connecting using TLS 1.2.

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Ssl3 Or SecurityProtocolType.Tls Or SecurityProtocolType.Tls11
           Dim binding As New BasicHttpBinding(BasicHttpSecurityMode.Transport)
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic
            binding.Security.Transport.Realm = ""
            SFMethodCall.Url = "https://cs101.my.salesforce.com/services/Soap/c/46.0/"

            Dim address As New EndpointAddress(SFMethodCall.Url)

            '' intiate request and pass header details including sessionID
            Dim mySessionHeader As New SFWSDL1.SessionHeader
            mySessionHeader.sessionId = SessionID
            Dim myAllOrNoneHeader As New SFWSDL1.AllOrNoneHeader
            myAllOrNoneHeader.allOrNone = True
  • Hi Samir.. Can you check any firewall at .Net side. If any blocking to make the connection.. Jun 24, 2019 at 10:01
  • @learningmode if this was firewall issue, i think they wouldn't even be able to get the session id using the login method.
    – Samir
    Jun 24, 2019 at 10:23
  • ok Samir.. Do u have any self signed or third party certificates? Jun 24, 2019 at 10:34
  • @learningmode - No. We are using username and password to get the sessionId
    – Samir
    Jun 24, 2019 at 10:52
  • Normal trust keyword is mostly linked with certificates...I can only think of using SSL Diagnostics Tool at .Net end to trace it... Jun 24, 2019 at 11:17

1 Answer 1


The WebException The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel is almost certainly related to support for TLS 1.2 as related to the Knowledge Article Salesforce Disabling TLS 1.1.

It is odd that the login call to https://test.salesforce.com completed where as the subsequent call to https://cs101.my.salesforce.com/services/Soap/c/46.0/ failed.

I assume setting the ServicePointManager.SecurityProtocol to support TLS 1.2 occured before the login call.

Firstly, I'd check that your .NET version has the required support. You should be aiming for .NET 4.5 or higher.

Also, check that there is OS level support for TLS 1.2. E.g. some older versions of Windows Server won't work.

If you still have problems check the login history - How to view all TLS 1.1 Logins. If there is a proxy server messing with the requests it may show up there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .