• .NET Framework

The request was aborted: Could not create SSL/TLS secure channel

Also seen in: PowerShell, HttpWebRequest, WebClient, WCF, Invoke-WebRequest, Invoke-RestMethod

In one sentence

Schannel could not finish the TLS handshake for a .NET Framework app: no TLS version or cipher suite in common, or a required client certificate was not sent.

Where you see it

In .NET Framework’s networking stack: HttpWebRequest, WebClient, HttpClient, WCF clients over HTTPS, and Windows PowerShell 5.1’s Invoke-WebRequest and Invoke-RestMethod.

System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.

Windows PowerShell prints it as Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel. The exception’s Status is WebExceptionStatus.SecureChannelFailure. The inner exception carries Schannel’s own text, listed in Microsoft’s COM error codes: The client and server cannot communicate, because they do not possess a common algorithm (SEC_E_ALGORITHM_MISMATCH) or The message received was unexpected or badly formatted (SEC_E_ILLEGAL_MESSAGE, Schannel’s code for a handshake_failure alert).

It is a Schannel handshake failure, not a trust failure. An untrusted certificate gives TrustFailure and a different message: The remote certificate is invalid or, in Windows PowerShell, Could not establish trust relationship. .NET Core and .NET 5 and later print The SSL connection could not be established, see inner exception. instead; this page is not for them.

What it means

.NET Framework hands the TLS handshake to Schannel, the Windows TLS library, which offers only the versions and cipher suites the application asked for and Windows has enabled. The handshake stopped before any certificate was checked: no TLS version or cipher suite in common, or the server wanted something the client did not send, a client certificate or, rarely, the server name (SNI).

What the app asks for depends on the .NET Framework version it targets and on two registry values. SchUseStrongCrypto makes outgoing connections use TLS 1.2 and 1.3; it is on by default for apps that target .NET Framework 4.6 or later. Older targets use .NET Framework’s own list, which Microsoft warns means SSL 3.0 and TLS 1.0. SystemDefaultTlsVersions lets Windows choose; it is on by default for apps that target .NET Framework 4.7 or later, and ServicePointManager.SecurityProtocol then reads SystemDefault from .NET Framework 4.7. WCF followed in .NET Framework 4.7.1, after defaulting to TLS 1.2 in 4.7. Windows has its own list, which hardening tools and Group Policy edit: TLS 1.1 and 1.2 are off on Windows 7 and Windows Server 2008 R2, Windows Server 2008 SP2 needs a patch first (update KB4019276), TLS 1.2 is on from Windows 8 and Windows Server 2012 onwards, and TLS 1.3 arrived with Windows 11 and Windows Server 2022.

Schannel logs the reason in the System log; error events are written by default (EventLogging level 1; 3 adds warnings).

Get-WinEvent -FilterHashtable @{ LogName = 'System'; ProviderName = 'Schannel' } -MaxEvents 20 |
    Format-List TimeCreated, Id, Message
Id      : 36887
Message : A fatal alert was received from the remote endpoint. The TLS protocol defined fatal alert code is 40.

Event 36887 carries the server’s alert code: 40 is handshake_failure, 70 protocol_version, 112 unrecognized_name. Event 36871 means Schannel could not even create a client credential.

Likely causes

The client offers only old TLS versions

The most common case: an old target still offers the old list, and one day the server stops accepting TLS 1.0. A Windows upgrade can also drop SchUseStrongCrypto (KB4458166, August 2018); Microsoft’s article quotes this exact exception.

Confirm: event 36887 with alert 40, or with protocol_version (code 70), or event 36871 (no version is both enabled in Windows and allowed by the app, per Microsoft’s registry documentation). If openssl s_client -connect api.example.com:443 -servername api.example.com -tls1_2 -brief connects, the client is the old side. See what it offers:

Get-ItemPropertyValue -LiteralPath 'HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -Name Release
Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319' |
    Select-Object SchUseStrongCrypto, SystemDefaultTlsVersions
[Net.ServicePointManager]::SecurityProtocol

A Release of 460798 or higher means 4.7 or later is installed; what counts is the version the app targets. Missing registry values are normal. SystemDefault on the last line is what you want; a fixed list such as Ssl3, Tls is the old behaviour.

Fix: Microsoft’s guidance is to not set a protocol at all: target .NET Framework 4.7 or later (4.8 or later for TLS 1.3), rebuild, and delete every ServicePointManager.SecurityProtocol = ... line, since an explicit value overrides the registry (code that must touch it sets SecurityProtocolType.SystemDefault). For an app you cannot rebuild, set both registry values, including the WOW6432Node path 32-bit processes read, and restart it:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SystemDefaultTlsVersions"=dword:00000001
"SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v4.0.30319]
"SystemDefaultTlsVersions"=dword:00000001
"SchUseStrongCrypto"=dword:00000001

Repeat under v2.0.50727 for .NET Framework 3.5; this also fixes Windows PowerShell. The per-app form is a <runtime> switch in the config file, on runtimes of 4.6.2 or later:

<AppContextSwitchOverrides value="Switch.System.Net.DontEnableSchUseStrongCrypto=false;Switch.System.Net.DontEnableSystemDefaultTlsVersions=false" />

The server only speaks an old TLS version

The reverse: the client follows current Windows, and the server has only TLS 1.0 on. Confirm: event 36887 with code 70, and openssl s_client -tls1_2 fails too, while Test-NetConnection -ComputerName api.example.com -Port 443 reports TcpTestSucceeded : True.

Fix the server. On Windows Server 2008 R2, enable TLS 1.2 under Schannel and restart the service (the change applies only to credentials opened afterwards):

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000000

Windows Server 2008 SP2 needs a patch first (update KB4019276). TLS 1.2 is already on from Windows 8 and Windows Server 2012 onwards, so there look for an Enabled of 0 left by a hardening tool. Other servers: How to configure TLS securely.

No cipher suite in common

Both sides speak TLS 1.2, but the server was hardened to a short list that the client’s Windows version lacks. Confirm: s_client -tls1_2 -brief prints the negotiated suite, the SSL Labs server test lists every suite a public server accepts, and a server you run logs event 36874 (a client offered nothing it supports). Fix the server’s list so it includes TLS 1.2 suites with ECDHE and AES-GCM, which current Windows offers.

The server wants a client certificate

With mutual TLS the server asks for a client certificate. If the request carries none, TLS 1.2 lets the server answer with a fatal handshake_failure alert (code 40, RFC 5246). Confirm: event 36887 with code 40; without -brief, s_client also lists the CA names the server accepts. Fix: attach the certificate, with its private key, to the request; the app’s account needs access to that key.

var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
var cert = store.Certificates
    .Find(X509FindType.FindByThumbprint, "0123ABCD...", validOnly: false)[0];

var request = (HttpWebRequest)WebRequest.Create("https://api.example.com/");
request.ClientCertificates.Add(cert);

HttpClient takes the same collection through WebRequestHandler.ClientCertificates, or HttpClientHandler.ClientCertificates from .NET Framework 4.7.1; WCF uses client.ClientCredentials.ClientCertificate.SetCertificate(...) or the <certificate> element under <clientCertificate>. See How to set up mutual TLS.

Less common: no server name, or Extended Master Secret

Connecting by IP address sends no server name, because SNI cannot carry an IP literal, and a server that needs the name to pick a certificate may abort with unrecognized_name (code 112, RFC 6066). Use the host name. Alert code 20 on a resumed session points at Extended Master Secret enforcement (updates released on or after 8 October 2019, CVE-2019-1318); Microsoft’s article quotes this exact exception and says to update the peer that lacks EMS, not to switch it off.

Check yours

Try it: Paste your errorOpen the full tool

Runs in your browser. Nothing you paste is sent anywhere.

The whole message or just the important line. A stack trace is fine; we look for the known parts.

Paste the exception, its inner exception or the Schannel event text. The finder tells a handshake problem from a certificate problem.

Learn why

Guided mission · free · no account · progress saves hereAssemble a trusted TLS connection — 7 minutesConnect key agreement, certificate validation and handshake proof before protecting application data.

Does your team keep hitting this?

Everyone can use the lessons. Team seats add earned credentials, invitations and a completion report, so you see who has finished.

See team training

Early edition. Written with AI assistance and checked against primary sources; an independent expert review is planned. Found a mistake? Tell us.

Last reviewed Edition 0.9