From 1df282b5e3746ad0e255d96088687f1e024adc20 Mon Sep 17 00:00:00 2001 From: Bhaarath Raguru Date: Tue, 21 Nov 2017 15:56:31 -0800 Subject: [PATCH 1/3] Set TLS version to 1.2 before making SOAP calls --- ServiceSamples/JsonConsoleApplication/Program.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ServiceSamples/JsonConsoleApplication/Program.cs b/ServiceSamples/JsonConsoleApplication/Program.cs index 9db5949..245a0ff 100644 --- a/ServiceSamples/JsonConsoleApplication/Program.cs +++ b/ServiceSamples/JsonConsoleApplication/Program.cs @@ -11,6 +11,15 @@ class Program static void Main(string[] args) { + /* Helpful Note: + * If you are targetting SOAP endpoints on Sandbox or Prod AX environemnts you MUST make sure to use TLS 1.2 + * .NET 4.5 supports TLS 1.2 but it is not the default protocol. The below statement can set TLS version explicity. + * Note that this statement may not work in .NET 4.0, 3.0 or below. + * Also note that in .NET 4.6 and above TLS 1.2 is the default protocol. + */ + + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + var request = HttpWebRequest.Create(GetUserSessionOperationPath); request.Headers[OAuthHelper.OAuthHeader] = OAuthHelper.GetAuthenticationHeader(); request.Method = "POST"; From 7a5cbc20f7da7c6ed60a13e806a117c0016969ff Mon Sep 17 00:00:00 2001 From: Bhaarath Raguru Date: Tue, 21 Nov 2017 16:13:57 -0800 Subject: [PATCH 2/3] Set TLS version to 1.2 in SoapConsoleApplication --- ServiceSamples/SoapConsoleApplication/Program.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ServiceSamples/SoapConsoleApplication/Program.cs b/ServiceSamples/SoapConsoleApplication/Program.cs index 243e1fc..7282470 100644 --- a/ServiceSamples/SoapConsoleApplication/Program.cs +++ b/ServiceSamples/SoapConsoleApplication/Program.cs @@ -1,6 +1,7 @@ using AuthenticationUtility; using SoapUtility.UserSessionServiceReference; using System; +using System.Net; using System.ServiceModel; using System.ServiceModel.Channels; @@ -13,6 +14,15 @@ class Program [STAThread] static void Main(string[] args) { + /* Helpful Note: + * If you are targetting SOAP endpoints on Sandbox or Prod AX environemnts you MUST make sure to use TLS 1.2 + * .NET 4.5 supports TLS 1.2 but it is not the default protocol. The below statement can set TLS version explicity. + * Note that this statement may not work in .NET 4.0, 3.0 or below. + * Also note that in .NET 4.6 and above TLS 1.2 is the default protocol. + */ + + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + var aosUriString = ClientConfiguration.Default.UriString; var oauthHeader = OAuthHelper.GetAuthenticationHeader(); From 0c6568c6c2c72572d30d8df8a27baf636962053c Mon Sep 17 00:00:00 2001 From: Bhaarath Raguru Date: Tue, 21 Nov 2017 16:27:53 -0800 Subject: [PATCH 3/3] Set TLS version to 1.2 before making any service request --- ServiceSamples/JsonConsoleApplication/Program.cs | 3 +-- ServiceSamples/ODataConsoleApplication/Program.cs | 9 +++++++++ ServiceSamples/PHPConsoleApplication/Program.cs | 9 +++++++++ ServiceSamples/SoapConsoleApplication/Program.cs | 3 +-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ServiceSamples/JsonConsoleApplication/Program.cs b/ServiceSamples/JsonConsoleApplication/Program.cs index 245a0ff..ed68c3e 100644 --- a/ServiceSamples/JsonConsoleApplication/Program.cs +++ b/ServiceSamples/JsonConsoleApplication/Program.cs @@ -11,8 +11,7 @@ class Program static void Main(string[] args) { - /* Helpful Note: - * If you are targetting SOAP endpoints on Sandbox or Prod AX environemnts you MUST make sure to use TLS 1.2 + /* When making service requets to Sandbox or Prod AX environemnts it must be ensured that TLS version is 1.2 * .NET 4.5 supports TLS 1.2 but it is not the default protocol. The below statement can set TLS version explicity. * Note that this statement may not work in .NET 4.0, 3.0 or below. * Also note that in .NET 4.6 and above TLS 1.2 is the default protocol. diff --git a/ServiceSamples/ODataConsoleApplication/Program.cs b/ServiceSamples/ODataConsoleApplication/Program.cs index 8bd9bcd..1a2c187 100644 --- a/ServiceSamples/ODataConsoleApplication/Program.cs +++ b/ServiceSamples/ODataConsoleApplication/Program.cs @@ -3,6 +3,7 @@ using ODataUtility.Microsoft.Dynamics.DataEntities; using System; using System.Linq; +using System.Net; namespace ODataConsoleApplication { @@ -12,6 +13,14 @@ class Program static void Main(string[] args) { + /* When making service requets to Sandbox or Prod AX environemnts it must be ensured that TLS version is 1.2 + * .NET 4.5 supports TLS 1.2 but it is not the default protocol. The below statement can set TLS version explicity. + * Note that this statement may not work in .NET 4.0, 3.0 or below. + * Also note that in .NET 4.6 and above TLS 1.2 is the default protocol. + */ + + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + // To test custom entities, regenerate "ODataClient.tt" file. // https://blogs.msdn.microsoft.com/odatateam/2014/03/11/tutorial-sample-how-to-use-odata-client-code-generator-to-generate-client-side-proxy-class/ diff --git a/ServiceSamples/PHPConsoleApplication/Program.cs b/ServiceSamples/PHPConsoleApplication/Program.cs index 7e430d1..9110a23 100644 --- a/ServiceSamples/PHPConsoleApplication/Program.cs +++ b/ServiceSamples/PHPConsoleApplication/Program.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Net; using System.Text; using System.Threading.Tasks; @@ -11,6 +12,14 @@ class Program { static void Main(string[] args) { + /* When making service requets to Sandbox or Prod AX environemnts it must be ensured that TLS version is 1.2 + * .NET 4.5 supports TLS 1.2 but it is not the default protocol. The below statement can set TLS version explicity. + * Note that this statement may not work in .NET 4.0, 3.0 or below. + * Also note that in .NET 4.6 and above TLS 1.2 is the default protocol. + */ + + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + string command = @"PHP.exe"; string phpArgs = "Program.php"; diff --git a/ServiceSamples/SoapConsoleApplication/Program.cs b/ServiceSamples/SoapConsoleApplication/Program.cs index 7282470..d3e0578 100644 --- a/ServiceSamples/SoapConsoleApplication/Program.cs +++ b/ServiceSamples/SoapConsoleApplication/Program.cs @@ -14,8 +14,7 @@ class Program [STAThread] static void Main(string[] args) { - /* Helpful Note: - * If you are targetting SOAP endpoints on Sandbox or Prod AX environemnts you MUST make sure to use TLS 1.2 + /* When making service requets to Sandbox or Prod AX environemnts it must be ensured that TLS version is 1.2 * .NET 4.5 supports TLS 1.2 but it is not the default protocol. The below statement can set TLS version explicity. * Note that this statement may not work in .NET 4.0, 3.0 or below. * Also note that in .NET 4.6 and above TLS 1.2 is the default protocol.