In my situation, removing "request.Credentials = CredentialCache.DefaultCredentials" fixed the problem.
The request was aborted: Could not create SSL/TLS secure channel
.Net Class Library is based on 4.5 and using HtmlAgilityPack, I was calling an https URL and it was working fine.
After the website is updated and will not support old browsers which are not TLS v1.2 compliant. Getting the error -
The request was aborted: Could not create SSL/TLS secure channel
Tried below article, still it is not working
.NET Runtime
-
Cheong00 3,481 Reputation points
2020-11-25T01:35:32.997+00:00 The linked article said that clearly - updated to v4.7+ will make it work by default. Is there any reason that prevents you to do so?
-
Xingyu Zhao-MSFT 5,366 Reputation points
2020-11-25T01:36:35.06+00:00 Hi @Sajith Gopalakrishnan Hema ,
As suggested in the document, have you tried to upgrade your application to .NET Framework 4.7 or later versions ? -
Sajith Gopalakrishnan Hema 1,041 Reputation points
2020-11-25T04:52:43.45+00:00 The SharePoint Server is installed on Windows Server 2012 R2 and the configuration as follows
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>In VS 2015, there is no option to upgrade to .NET Framework 4.7 and when i did it to .net 4.7 from another machine also the same error persist.
Tried all below option.Still unable to use HtmlAgilityPack. Please suggest
-
Sajith Gopalakrishnan Hema 1,041 Reputation points
2020-11-25T07:58:43.62+00:00 I upgraded to .Net Framework 4.7 from another machine. Still it did not work.
-
Xingyu Zhao-MSFT 5,366 Reputation points
2020-11-25T08:00:14.893+00:00 Hi @Sajith Gopalakrishnan Hema ,
Considering that you may need to switch to Tls13, try to upgrade your app to .NET Framework 4.8 which has supported Tsl13.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13;
-
Sajith Gopalakrishnan Hema 1,041 Reputation points
2020-11-25T10:12:12.087+00:00 In the code, I need to use this right ? - ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13;
what about support runtime.
I tried the below options before. But it did not work.
Do I need to change anything in the App.Config
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup> -
Sajith Gopalakrishnan Hema 1,041 Reputation points
2020-11-25T12:58:23.917+00:00 From the Window Server 2012 R2, the solution is not working. But the same solution works in Windows 10 Machine if the target framework is .net framework 4.5.2
When we change target frame work to .net framework 4.8, and update the code with ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13;
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>Getting the following error in Windows 10 machine.
-
Sajith Gopalakrishnan Hema 1,041 Reputation points
2020-11-26T05:41:28.057+00:00 works in Windows 10 machine. But I need to run it from Windows Server 2012 R2 Machine. Please advise.
-
Sajith Gopalakrishnan Hema 1,041 Reputation points
2020-11-29T13:57:36.557+00:00 Pleas advise
-
Cheong00 3,481 Reputation points
2020-11-30T01:17:07.983+00:00 In that case the only way would make it work would be to use the other SSL libraries. .NET framework uses SChannel to provide HTTPS encryption, however TLS1.3 is not supported on Win2012R2 version there. (In fact, as of now the only Windows version have TLS1.3 support is Win10. It's not supported on any of the Windows Server versions)
If the server have Chromium based Edge, you may also consider change to use WebView2 control instead because Chromium doesn't use SChannel either. If you want to choose this route, it's worthwhile to take a look at the WebView2Brower project that is created by the Edge team to create a browser solely with WebView2 control.
-
Cheong00 3,481 Reputation points
2020-12-01T08:15:10.357+00:00 FYI, if we're talking about TLS 1.3, since SSL encryption of .NET Framework is provided by SChannel Windows Service, and currently only Win10 have TLS1.3 support (i.e.: none of the Windows Server version have TLS 1.3) you'll have to wait for an update for Windows Server 2019 and upgrade there in order to work. (I doubt if Microsoft will backport it to earlier system.)
If you need TLS1.3 support real fast, consider rewrite to use OpenSSL or other libraries instead.
-
Sajith Gopalakrishnan Hema 1,041 Reputation points
2020-12-01T13:03:15.653+00:00 Still I am using TLS 1.2 in the application from Windows 10 (not TLS 1.3) and it is working.
Can I use HtmlAgilityPack with OpenSSL ? do you have additional information ?
-
Cheong00 3,481 Reputation points
2020-12-02T01:33:37.167+00:00 No, to use OpenSSL, you'll literally need to rewrite that part from scratch, so only do that if there is urgent need to use TLS 1.3. (Some sites such as devblogs.microsoft.com upgraded to allow TLS 1.3 only. So if I started Fiddler on Win7, I cannot access it with HTTPS decryption turned on)
This information is for the topic on TLS 1.3 only, not something directly related to your problem.
Follow the Premier Developer blog if you want to monitor the announcement of TLS1.3 support on servers.
-
Sajith Gopalakrishnan Hema 1,041 Reputation points
2021-01-13T04:50:42.897+00:00 Please find below the protocol and cipher supported by the URL
-
Anonymous
2023-11-29T06:27:37.3066667+00:00 Hi I am using .Net Framework 4.7, but still I am getting same error. even I tried with .Net framework 4.8 but didn't work showing error as follows. Pls help me out.
The request was aborted: Could not create SSL/TLS secure channel.
__Description:__An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
__Exception Details:__System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
Sign in to comment
6 answers
Sort by: Most helpful
-
Raymond Ford 0 Reputation points
2023-10-10T13:53:05.0133333+00:00