SBX - Search With Button

SBX - Forum Post Title

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. in d365fo

Dynamics 365 for Finance and Operations Forum

Surjit Kumar asked a question on 14 Jun 2019 1:46 AM

Question Status

Unanswered

I am trying to integrate e-commerce with D365 FO(PU-Update24 (7.0.5179.35392)). I have a service URL from third-party e-commerce to invoke it in D365 Fo.

I have written required classes to consume the URL and generate XML and send to the URL.

From Ax, I am generating the XML request and passing it to a third party application, but I am getting below error.

When I am trying to invoke the external web service URL and send the XML as a parameter to the web service URL I'm getting the error "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."

Can you guys help me on this?

Reply
Anand S responded on 17 Jun 2019 12:18 AM
My Badges

Hi Surjit,

Have you tried debugging the code, It seems SSL validation needs to be removed by your code.

Reply

Try below line of code , before calling external service.

InteropPermission(InteropKind::ClrInterop).assert();
            System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Tls12);


Reply
Surjit Kumar responded on 17 Jun 2019 1:41 AM

Hi Sukrut Parab,

I tried the above line of code, but still getting the same issue.

below is the line of code added:

new InteropPermission(InteropKind::ClrInterop).assert();

       System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Tls12);

       webreq.set_Method("POST");

       webreq.set_ContentType("text/xml");

       streamstr = webreq.GetRequestStream();

       streamWriter = new System.IO.StreamWriter(streamstr);

       streamWriter.Write(System.Web.HttpUtility::UrlEncode("xmlcontent="+xml))

       streamWriter.Flush();

       streamWriter.Close();

       streamWriter.Dispose();

       webresponse = webreq.GetResponse();

       responsestr = webresponse.GetResponseStream();

       reader = new System.IO.StreamReader(responsestr);

       info(reader.ReadToEnd());

getting the error in the above highlighted line

Reply

SBX - Two Col Forum

SBX - Migrated JS