Skip to content

Add SChannel TLS 1.3 support - #8419

Closed
wyattoday wants to merge 1 commit into
curl:masterfrom
wyattoday:schannel-ng
Closed

wyattoday wants to merge 1 commit into
curl:masterfrom
wyattoday:schannel-ng

Conversation

@wyattoday

@wyattoday wyattoday commented Feb 9, 2022 •

Copy link
Copy Markdown
Contributor

Add SChannel TLS 1.3 support to curl / libcurl. This is a rework of the previous SChannel TLS 1.3 PR, built on curl-main, and finishing the remaining TODO.

This adds TLS 1.3 support for versions of Windows that support it at runtime. No-need for compile-time shenanigans.

Also, added a new define to disable optional code: DISABLE_SCHANNEL_CLIENT_CERT (reduces compiled code size if that feature is not needed in the vein of tinycurl).

SChannel currently only supports the following ciphers:

TLS_AES_256_GCM_SHA384
TLS_CHACHA20_POLY1305_SHA256
TLS_AES_128_GCM_SHA256

The following are not currently supported (but also not negotiated):

TLS_AES_128_CCM_8_SHA256
TLS_AES_128_CCM_SHA256 

And TLS_CHACHA20_POLY1305_SHA256 is supported, but disabled by default in Windows (it can be enabled).

In addition to all the code required to add this, I've also modified the "SSL Ciphers" and "CURLOPT_TLS13_CIPHERS explained" docs to add the new options and document when the functionality was introduced.

@bagder bagder added TLS Windows Windows-specific labels Feb 9, 2022
Comment thread lib/vtls/schannel.c Resolved
Comment thread lib/vtls/schannel.c Resolved
Comment thread lib/vtls/schannel.c Resolved
Comment thread lib/vtls/schannel.c Resolved
@bagder

bagder commented Feb 10, 2022

Copy link
Copy Markdown
Member

@jay @MarcelRaad please give this PR a glance!

Comment thread lib/vtls/schannel.h Resolved
Comment thread lib/vtls/schannel.h Resolved
Comment thread lib/vtls/schannel.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, could this be moved to where an actual error occurs? I like the clear error message, but if someone actually wants to use TLS 1.3 on Windows 10 or whatever other OS, why prevent them from doing so?

@wyattoday wyattoday Feb 10, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, SChannel is inherently tied to the version of Windows. And Windows 11 / Windows 2022 is when TLS 1.3 was introduced as a finished feature (yes, there were buggy registry-enabled versions in the later Windows 10 builds).

So, if a user explicitly requests TLS 1.3 on a version of Windows that doesn't support it then they will get an error ASAP.

However, the max TLS version will be set correctly at runtime (if not set by the user). See: https://github.com/curl/curl/pull/8419/files#diff-518f418eae7110255d54ce052e3f17412cfc2289fd2c31cded6fec437ee58333R201

If you're talking about Windows emulators, then that's a whole other bag of worms. But if they're emulating correctly (accurately) then they should have the exact same behavior as Windows.

Comment thread lib/vtls/schannel.c Resolved
@MarcelRaad

MarcelRaad commented Feb 15, 2022 •

Copy link
Copy Markdown
Member

Looks good to me now except for the build break with Visual Studio 2008 (see AppVeyor), and I'd feel more comfortable if we had our MinGW CI on Azure Pipelines back up before merging.

@MarcelRaad MarcelRaad added the feature-window A merge of this requires an open feature window label Feb 15, 2022
@jay

jay commented Feb 15, 2022

Copy link
Copy Markdown
Member

Looks good to me now except for the build break

We need to investigate why it's necessary to set pDisabledCrypto, that does not make sense to me. It seems as though the MS TLS 1.3 support is half baked if it requires explicitly disabling certain TLS 1.3 algorithms.

@bagder

bagder commented Mar 11, 2022

Copy link
Copy Markdown
Member

"This branch cannot be rebased due to conflicts"

Please rebase (and feel free to squash into fewer commits) and force-push to this branch.

@curl curl deleted a comment from Cmo1976 Mar 11, 2022
@wyattoday

wyattoday commented Mar 11, 2022 •

Copy link
Copy Markdown
Contributor Author

@bagder Merged with upstream "master". Should be good to go.

@bagder

bagder commented Mar 11, 2022

Copy link
Copy Markdown
Member

We rebase and do a clean and "straight" commit history when we merge. So it needs to rebase without conflict.

@wyattoday

Copy link
Copy Markdown
Contributor Author

Ok.

I gotta be honest, at our company we merge PRs with full history, so I have little experience with the git magic in re-writing the history. And the git docs are as clear as mud on this point.

So, if I have time at the end of today I'll work on it. Otherwise I'll work on it sometime next week.

@jay

jay commented Mar 12, 2022

Copy link
Copy Markdown
Member

We need to investigate why it's necessary to set pDisabledCrypto, that does not make sense to me. It seems as though the MS TLS 1.3 support is half baked if it requires explicitly disabling certain TLS 1.3 algorithms.

I still think one of us familiar with Windows should investigate this before landing. Basically we need to know how Windows 10 and 11 TLS 1.3 behaves without explicitly disabling any ciphers.

@gvollant

Copy link
Copy Markdown
Contributor

Microsoft distribute curl.exe with SChannel with Windows 10, pehaps they can help curl team !

@wyattoday

wyattoday commented Mar 22, 2022 •

Copy link
Copy Markdown
Contributor Author

@bagder @jay Should I do the work of squashing the commits so it can be merged? Or should I wait for more reviews by other users?

I'm getting mixed signals.

Does this work by adding TLS 1.3 to curl with SChannel? Yes. (We're using it in production right now).

Does this use all the publicly available documentation and implement it based on that? Also, yes.

Is the SChannel API a black-box with shitty public documentation? Also, yes.

@jay

jay commented Mar 22, 2022

Copy link
Copy Markdown
Member

Please squash. If you run into squash errors that look time consuming then try working from a temporary branch based off of upstream/master.

git fetch upstream
git checkout -b temp upstream/master
git merge --squash schannel-ng
git commit # consolidate commit messages into one
git checkout schannel-ng
git reset --hard temp
git branch -D temp
git push -f origin

I'm assuming in this example that remotes upstream => curl/curl and origin => wyattoday/curl

@wpodgorski

Copy link
Copy Markdown

@wyattoday @jay any update on this :)?

@gvollant

gvollant commented May 9, 2022

Copy link
Copy Markdown
Contributor

This will be wonderfull if this feature can be included in next version @wyattoday

@wyattoday

Copy link
Copy Markdown
Contributor Author

Sorry, been super busy. I’ll get to this end of next week.

@Andrei-Popov

Copy link
Copy Markdown

We need to investigate why it's necessary to set pDisabledCrypto, that does not make sense to me. It seems as though the MS TLS 1.3 support is half baked if it requires explicitly disabling certain TLS 1.3 algorithms.

I own schannel. There is no need to disable algorithms. Unsupported cipher suites, etc., obviously, won't get negotiated.

@wyattoday

wyattoday commented Jun 4, 2022 •

Copy link
Copy Markdown
Contributor Author

@Andrei-Popov

I own schannel.

You work at MS?

There is no need to disable algorithms. Unsupported cipher suites, etc., obviously, won't get negotiated.

Do you happen to have a link (or a reference to any public documentation) that says as much?

The docs I’ve read are all public (obviously — I don’t work at MS) and suggest the opposite. But I would happy to be proven wrong (because it makes more sense for the way I’ve implemented it right now to be the wrong way).

It’s not that I don’t believe you, it’s just that it would better to have canonical sources that can be referred to rather than (a) guesses (b) referencing other source code examples {what I did here} or (c) lore passed down in mailing lists and issues trackers.

vszakats added a commit to vszakats/curl that referenced this pull request Sep 21, 2023
The comment and PR history doesn't tell more or mention
mingw version, so take a chance on this and assume it
affected old mingw.

My fresh copy of mingw-w64 does have an `ARRAYSIZE()`
macro defined by Windows headers.

Originally added in 8beff43 curl#8419
vszakats added a commit that referenced this pull request Feb 11, 2026
- define `SECURITY_WIN32` globally in `curl_setup.h`.
  To make sure it applies to all includes.

- document which Windows headers require `SECURITY_WIN32`.

- stop suppressing MSVC warning:
  `C4201 is: nonstandard extension used : nameless struct/union`
  The warning is no longer seen in supported build envs with the current
  codebase.
  Follow-up to 8beff43 #8419

- document why `SCHANNEL_USE_BLACKLISTS` is needed.

- just define `SCHANNEL_USE_BLACKLISTS`, drop the unnecessary value `1`.

- stop defining unused `SCH_CRED_MAX_SUPPORTED*` fallback macros.
  Follow-up to 8beff43 #8419

- document why `subauth.h` is included (where missing).

- move and de-dupe `subauth.h` include into `curl_setup.h`, limit to
  Schannel builds.

- stop include `schnlsp.h`. It is a 1-to-1 compatibility wrapper for
  `schannel.h`.

- curl_sspi.h: clarify comment about `SP_NAME_` macros.
  They are local macros, their SDK names are different and curl does not
  use them.

- curl_sspi.h: drop superfluous includes `security.h` and `rpc.h`.

Cherry-picked from #20556

Closes #20564
vszakats added a commit to vszakats/curl that referenced this pull request Mar 19, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Mar 19, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Mar 21, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Mar 27, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Mar 27, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Mar 28, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Apr 1, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Apr 5, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Apr 6, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Apr 6, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Apr 6, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Apr 7, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Apr 8, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Apr 8, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Apr 13, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Apr 13, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature-window A merge of this requires an open feature window TLS Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

8 participants