I am getting error saying "The request was aborted: Could not create SSL/TLS secure channel" while consuming a third party API in my code. The code works fine when runs on Windows10 or Windows Server 2016 r2 but giving above error on Wndows7 and Windows
Server 2012 R2.
I am getting error saying "The request was aborted: Could not create SSL/TLS secure channel" while consuming a third party API in my code. The code works fine when runs on Windows10 or Windows Server 2016 r2 but giving above error on Wndows7 and Windows Server
2012 R2.
I am afraid that there is not enough environment to test the code you provided.
And after some searching, I found that the problem may be related to your
ServicePointManager settings.
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
I am getting error saying "The request was aborted: Could not create SSL/TLS secure channel" while consuming a third party API in my code. The code works fine when runs on Windows10 or Windows Server 2016 r2 but giving above error on Wndows7 and Windows
Server 2012 R2.
<?xml version="1.0"?><!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301879
--><configuration><connectionStrings><addname="IDGDB"connectionString="Data Source=localhost;initial catalog=mydatabase;user id=sa;password=1234;"providerName="System.Data.SqlClient"/></connectionStrings><appSettings><addkey="LogPath"value="C://ReverseAPILogs"/><addkey="PrintDetailedLogs"value="2"/><addkey="oAuthAPIURL"value="https://thirdpartysite.com/oauth/token"/><addkey="authusername"value="bf41ac5b-xxx-xxxx"/><addkey="authpassword"value="********"/><addkey="scope"value="CustomerServicing"/><addkey="username"value="********"/><addkey="password"value="********0"/><addkey="onboardingAPIURL"value="https://thirdpartysite.com/xxx/agenton/v1"/><addkey="X-IBM-Client-Id"value="*********"/><addkey="X-IBM-Client-Secret"value="**************"/><addkey="sourceSystem"value="AMS"/><addkey="sourceOfLead"value="W2R"/><addkey="soaAppId"value="MREC"/></appSettings><!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.7" />
</system.Web>
--><system.web><compilationdebug="true"targetFramework="4.5"/><httpRuntimetargetFramework="4.5"/></system.web><system.webServer><handlers><removename="ExtensionlessUrlHandler-Integrated-4.0"/><removename="OPTIONSVerbHandler"/><removename="TRACEVerbHandler"/><addname="ExtensionlessUrlHandler-Integrated-4.0"path="*."verb="*"type="System.Web.Handlers.TransferRequestHandler"preCondition="integratedMode,runtimeVersionv4.0"/></handlers></system.webServer><runtime><assemblyBindingxmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentityname="System.Web.Helpers"publicKeyToken="31bf3856ad364e35"/><bindingRedirectoldVersion="1.0.0.0-3.0.0.0"newVersion="3.0.0.0"/></dependentAssembly><dependentAssembly><assemblyIdentityname="System.Web.Mvc"publicKeyToken="31bf3856ad364e35"/><bindingRedirectoldVersion="1.0.0.0-5.2.3.0"newVersion="5.2.3.0"/></dependentAssembly><dependentAssembly><assemblyIdentityname="System.Web.WebPages"publicKeyToken="31bf3856ad364e35"/><bindingRedirectoldVersion="1.0.0.0-3.0.0.0"newVersion="3.0.0.0"/></dependentAssembly></assemblyBinding></runtime><system.codedom><compilers><compilerlanguage="c#;cs;csharp"extension=".cs"type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"warningLevel="4"compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/><compilerlanguage="vb;vbs;visualbasic;vbscript"extension=".vb"type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"warningLevel="4"compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/></compilers></system.codedom></configuration>
Still getting same error message "The request was aborted: Could not create SSL/TLS secure channel." after adding suggested piece of code.
How do you modify the code, you need to make sure the ServicePointManager settings are made before the HttpWebRequest is created, else it will not work.
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
I have enabled Tls1.1 and 1.2 in WinHTTP also made service point manager setting before Webrequest but still getting same error "The request was aborted: Could not create SSL/TLS secure channel".
In addition to XuDong Peng suggestion, you can try Enable all possible SSL/TLS versions to check if any fix your issue, then play with each other to identify what best fit your needs, of course it is defined by Server you are sending data.
To enable SSL, TLS1.1 and TLS1.2 on .NET you can use:
System.Net.ServicePointManager.SecurityProtocol = System.Net.ServicePointManager.SecurityProtocol Or System.Net.SecurityProtocolType.Tls11 Or System.Net.SecurityProtocolType.Tls12
I also use Win7 & W2k12. Here is a controversial part. As far link above suggests an Update, "in my case" it was not necessary to apply it. Just enable protocols version was enough.
Member
31 Points
188 Posts
WebRequest Error The request was aborted: Could not create SSL/TLS secure channel - Windows 7
Feb 05, 2021 01:30 AM|shashikant2011|LINK
Hi ,
I am getting error saying "The request was aborted: Could not create SSL/TLS secure channel" while consuming a third party API in my code. The code works fine when runs on Windows10 or Windows Server 2016 r2 but giving above error on Wndows7 and Windows Server 2012 R2.
WebRequest Code:
Here is my Web.Config Settings:
Please help!
Contributor
2340 Points
736 Posts
Re: WebRequest Error The request was aborted: Could not create SSL/TLS secure channel - Windows 7
Feb 05, 2021 08:04 AM|XuDong Peng|LINK
Hi shashikant2011,
I am afraid that there is not enough environment to test the code you provided.
And after some searching, I found that the problem may be related to your ServicePointManager settings.
In Windows 7, you could try add these code:
You could also refer to this case below for more possibly solutions.
https://stackoverflow.com/questions/2859790/the-request-was-aborted-could-not-create-ssl-tls-secure-channel
Best regards,
Xudong Peng
Member
31 Points
188 Posts
Re: WebRequest Error The request was aborted: Could not create SSL/TLS secure channel - Windows 7
Feb 05, 2021 10:02 AM|shashikant2011|LINK
Still getting same error message "The request was aborted: Could not create SSL/TLS secure channel." after adding suggested piece of code.
Please help!
Member
31 Points
188 Posts
Re: WebRequest Error The request was aborted: Could not create SSL/TLS secure channel - Windows 7
Feb 09, 2021 11:44 PM|shashikant2011|LINK
Please help I am stuck.
Contributor
2340 Points
736 Posts
Re: WebRequest Error The request was aborted: Could not create SSL/TLS secure channel - Windows 7
Feb 10, 2021 06:19 AM|XuDong Peng|LINK
Hi shashikant2011,
How do you modify the code, you need to make sure the ServicePointManager settings are made before the HttpWebRequest is created, else it will not work.
Something like this:
As the response in this case said: https://stackoverflow.com/questions/2859790/the-request-was-aborted-could-not-create-ssl-tls-secure-channel/50977774#50977774
Have you enable TLS 1.1 and TLS 1.2 as default secure protocols in WinHTTP in Windows? You could refer to this document:
https://support.microsoft.com/en-us/topic/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-winhttp-in-windows-c4bd73d2-31d7-761e-0178-11268bb10392
Best regards,
Xudong Peng
Member
31 Points
188 Posts
Re: WebRequest Error The request was aborted: Could not create SSL/TLS secure channel - Windows 7
Feb 12, 2021 05:20 AM|shashikant2011|LINK
I have enabled Tls1.1 and 1.2 in WinHTTP also made service point manager setting before Webrequest but still getting same error "The request was aborted: Could not create SSL/TLS secure channel".
Participant
1091 Points
673 Posts
Re: WebRequest Error The request was aborted: Could not create SSL/TLS secure channel - Windows 7
Feb 12, 2021 08:59 PM|jzero|LINK
In addition to XuDong Peng suggestion, you can try Enable all possible SSL/TLS versions to check if any fix your issue, then play with each other to identify what best fit your needs, of course it is defined by Server you are sending data.
To enable SSL, TLS1.1 and TLS1.2 on .NET you can use:
It works on Win10 & W2k16 because, by default they are enable, but they are not enabled on Win7 & W2k12 check "Figure1 - Security Protocol Support By OS Version" at https://docs.microsoft.com/en-us/security/engineering/solving-tls1-problem
I also use Win7 & W2k12. Here is a controversial part. As far link above suggests an Update, "in my case" it was not necessary to apply it. Just enable protocols version was enough.
May be your next issue can be an exception with message "The remote certificate is invalid according to the validation procedure", for this particular issue check my answer https://forums.asp.net/t/2157003.aspx?The+remote+certificate+is+invalid+according+to+the+validation+procedure
Attention changes on ServicePointManager are Global