INTERNET APPLICATION DEVELOPMENT
MID MARKET ERP DEVELOPMENT
by Jacky Xu
Recently, our Intacct projects keep getting the error “The request was aborted: Could not create SSL/TLS secure channel” when the program request posts to Intacct web site. So, I searched for the solution from the website. Some blogs said, “Many companies have disabled SSLv3.” and “TLS is the standard protocol in .NET for a few years and SSLv3 is just used as a fallback.” But, I’m not sure Intacct did that. I think we can add some code to force the project to use “TLS” as a security communication protocol. Finally, I add one line of code to a project:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
I also published the changes to the Windows Azure website and tested it. It works now.
Forget to mention, I also added the line to the “Application_Start()” in the “Global.asax.cs”. But, I think you can also add the code before your posting request code.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://www.intacct.com/ia/xml/xmlgw.phtml");
var req = new HttpRequestMessage(HttpMethod.Post, "");
req.Content = new StringContent(request.OuterXml, Encoding.UTF8, "application/x-intacct-xml-request");
HttpResponseMessage response = await client.SendAsync(req).ConfigureAwait(false);