<!-- https://pkizerotohero.com/errors/dotnet-could-not-create-ssl-tls-secure-channel/ | Markdown mirror of the HTML page | PKI Zero to Hero, by Duyutech BV -->

> Fix .NET Framework's Could not create SSL/TLS secure channel: read the Schannel event, then fix the TLS version, cipher suite or client certificate.

Source: https://pkizerotohero.com/errors/dotnet-could-not-create-ssl-tls-secure-channel/ · Last reviewed: 2026-10-24

- .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.

[Check yours: Paste your error](https://pkizerotohero.com/tools/error-finder/)

## 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`.

```text
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](https://learn.microsoft.com/en-us/windows/win32/com/com-error-codes-4): `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](https://pkizerotohero.com/errors/dotnet-remote-certificate-invalid/) or, in Windows PowerShell, [Could not establish trust relationship](https://pkizerotohero.com/errors/powershell-could-not-establish-trust/). .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](https://pkizerotohero.com/handbook/glossary/#tls-handshake) to Schannel, the Windows TLS library, which offers only the versions and [cipher suites](https://pkizerotohero.com/handbook/glossary/#cipher-suite) 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](https://pkizerotohero.com/handbook/glossary/#client-certificate) or, rarely, the server name ([SNI](https://pkizerotohero.com/handbook/glossary/#server-name-indication)).

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).

```powershell
Get-WinEvent -FilterHashtable @{ LogName = 'System'; ProviderName = 'Schannel' } -MaxEvents 20 |
    Format-List TimeCreated, Id, Message
```

```text
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:

```powershell
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:

```ini
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:

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

Warning

Last resort: pinning the version in code

If you can change the code but not the target or the registry, pin the version once at startup. .NET Framework 3.5 has no `Tls12` member; Microsoft’s workaround is the cast (SecurityProtocolType)3072.

```csharp
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
```

Windows PowerShell’s equivalent, from Microsoft’s PowerShell Gallery instructions, is `[Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12`. Microsoft advises against it: the process never gains TLS 1.3, ignores Windows policy, and the line outlives TLS 1.2.

### 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):

```ini
[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](https://pkizerotohero.com/guides/tls-configuration/).

### 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](https://pkizerotohero.com/handbook/glossary/#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](https://pkizerotohero.com/handbook/glossary/#private-key), to the request; the app’s account needs access to that key.

```csharp
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](https://pkizerotohero.com/guides/mutual-tls-setup/).

### 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.

Warning

Two bypasses that do not help

`ServicePointManager.ServerCertificateValidationCallback = (s, c, ch, e) => true;` does nothing here: it runs when the server’s certificate is checked, which this handshake never reaches. It does stay in the code after the real fix, and then the app accepts any certificate, which is what a [man-in-the-middle](https://pkizerotohero.com/handbook/glossary/#man-in-the-middle) needs. Re-enabling SSL 3.0 or TLS 1.0 on a server reopens the attacks those versions were retired for; fix the client’s protocol list instead.

## Check yours

*Interactive tool: Paste your error (runs in the browser at [/tools/error-finder/](https://pkizerotohero.com/tools/error-finder/))*

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

## Learn why

- [The TLS 1.3 handshake](https://pkizerotohero.com/handbook/tls-handshake/): how versions and cipher suites are agreed.
- Related: [The remote certificate is invalid](https://pkizerotohero.com/errors/dotnet-remote-certificate-invalid/) and [Could not establish trust relationship](https://pkizerotohero.com/errors/powershell-could-not-establish-trust/) (the trust failure from the same stack), [handshake\_failure in Java](https://pkizerotohero.com/errors/java-handshake-failure/) and [How to configure TLS securely](https://pkizerotohero.com/guides/tls-configuration/).
- Microsoft: [TLS best practices with .NET Framework](https://learn.microsoft.com/en-us/dotnet/framework/network-programming/tls), [TLS registry settings](https://learn.microsoft.com/en-us/windows-server/security/tls/tls-registry-settings), [KB4458166](https://support.microsoft.com/kb/4458166) (`SchUseStrongCrypto` after a Windows upgrade), [KB4019276](https://support.microsoft.com/help/4019276) (TLS 1.2 on Windows Server 2008 SP2) and [KB4528489](https://support.microsoft.com/help/4528489) (Extended Master Secret).

**Early edition.** Written with AI assistance and checked against primary sources; an independent expert review is planned. Found a mistake? [Tell us](https://pkizerotohero.com/contact/?topic=content-error&page=/errors/dotnet-could-not-create-ssl-tls-secure-channel/).

Last reviewed 24 October 2026Edition 0.9

## Learn why it happens

- [Chapter 15: The TLS 1.3 handshake](https://pkizerotohero.com/handbook/tls-handshake/)

## Everything on this topic

- [TLS and HTTPS](https://pkizerotohero.com/topics/tls/)
