Repository navigation
Conversation
…ible version checking). This fixes ALPN with executables without the proper manifest. Also begins support for TFO and TLS 1.3 on Windows.
…en using non-MS compilers on MS Windows.
Has detection at runtime to enable / disable support depending on version of Windows. Also, add 2 new defines to disable redundant code: DISABLE_SCHANNEL_MANUAL_VERIFY (SChannel already handles verification internally) and DISABLE_SCHANNEL_CLIENT_CERT (reduces compiled code size if that feature is not needed). A bit more work needs to be done before this is "merge-ready", but TLS 1.3 support is working.
| if(curlx_verify_windows_version(10, 0, 17763, PLATFORM_WINNT, | ||
| VERSION_GREATER_THAN_EQUAL)) { | ||
|
|
||
| SCH_CREDENTIALS Credentials = { 0 }; |
There was a problem hiding this comment.
We normally use lower-case names for local variables.
There was a problem hiding this comment.
I'll fix those tomorrow, thanks.
There was a problem hiding this comment.
Never mind, had a free minute. Fixed now.
| goto cleanup; | ||
| } | ||
| if(BACKEND->encdata_offset) { | ||
| if(BACKEND->encdata_offset && inbuf[1].cbBuffer) { |
There was a problem hiding this comment.
This change seems unrelated to TLS 1.3.
There was a problem hiding this comment.
It is required. I spent a few days mulling over and debugging what exactly was happening. With the new SChannel support of SCH_CREDENTIALS, inbuf[1] can be empty while encdata_offset is not empty when receiving a SEC_I_RENEGOTIATE return code.
Unfortunately, MS's documentation on this behavior is slim, so I can't tell you why this is the case, just that it is the case.
Long story short: without this change SCH_CREDENTIALS support (and thus TLS 1.3 support) will fail.
There was a problem hiding this comment.
Understood, but what happens for applications not using TLS 1.3 following the old code path?
There was a problem hiding this comment.
Same working behavior when using TLS 1.2 (or older) on either the SCH_CREDENTIALS or SCHANNEL_CRED code-paths.
There was a problem hiding this comment.
It looks like this change effectively renders the check moot. I added the check in 3e7ec1e, but going through it just now I can't remember why. Maybe I thought it was not possible that encrypted data would be sent before the renegotiate completed? However my note in the commit message contradicts that guess:
- Do not recurse on renegotiation.
Instead we'll continue on to process any trailing encrypted data
received during the renegotiation only.
So I think my intention was to process that data.
edit: Update... on further review I actually did intend to error there because apparently I saw that's what chromium or microsoft did. Maybe at the time there was no scenario where it could happen. See this comment (Note I manually tested renegotiation later on, but we don't have an automated test for it).
There was a problem hiding this comment.
Unfortunately I couldn't reproduce a case where SEC_I_RENEGOTIATE was received, BACKEND->encdata_offset was != 0 and it wasn't just faulty error handling. The code still handles the case where inbuf[1].cbBuffer == 0 and inbuf[3].cbBuffer != 0. But is that necessary (or is it a code-path that will never be executed)? I have no idea -- I couldn't reproduce a case that got that result.
Unfortunately that commit message and those PR discussions didn't get me any closer to reproducing a test-case.
Edit:
If there doesn't exist a test-case for this behavior, I'm fine with removing that chunk of code entirely:
if(BACKEND->encdata_offset && inbuf[1].cbBuffer) {
*err = CURLE_RECV_ERROR;
infof(data, "schannel: can't renegotiate, "
"encrypted data available");
goto cleanup;
}
All of the tests I've run on supported versions of Windows have worked fine without that check present.
| !BACKEND->recv_sspi_close_notify) { | ||
| bool isWin2k = curlx_verify_windows_version(5, 0, PLATFORM_WINNT, | ||
|
|
||
| #if defined(_WIN32_WINNT) && _WIN32_WINNT <= 0x0500 |
There was a problem hiding this comment.
I do not understand the whole thing of combining runtime and compile time checks like this. What is the purpose here?
There was a problem hiding this comment.
Removing dead code-paths (smaller compiled binary). This is inherited from the other PR that this PR depends on: #7727
There was a problem hiding this comment.
I don't think this is worth the effort as it over-complicates the code and makes reading it a lot harder. Generally speaking we try to perform Windows specific checks during runtime, because it is common for a Windows application to be build on a one platform version and then shipped to a couple of others. Therefore compile-time checks do not make much sense with the Windows ecosystem.
|
Hello @wyattoday , I suggest you rebase and do a git fixup / squash to merge all (or somes of) your commit |
| #ifdef __MINGW32__ | ||
| #include <_mingw.h> | ||
| #ifdef __MINGW64_VERSION_MAJOR | ||
| #if defined(__MINGW64_VERSION_MAJOR) && !defined(DISABLE_SCHANNEL_MANUAL_VERIFY) |
There was a problem hiding this comment.
I think the two new flags/options DISABLE_SCHANNEL_MANUAL_VERIFY and DISABLE_SCHANNEL_CLIENT_CERT should be done in a separate PR as this is unrelated to TLS 1.3.
(SChannel already handles verification internally)
Also this is not true for all versions of Windows.
There was a problem hiding this comment.
Also this is not true for all versions of Windows.
Really? From my research (again, documentation is spotty on MSDN), auto-verification has been supported since at least Windows 2000.
Either way, I can make a separate PR that adds those 2 options. Or better yet, adds the inverse of DISABLE_SCHANNEL_MANUAL_VERIFY (ENABLE_SCHANNEL_MANUAL_VERIFY) so that by-default end-users will be smaller binaries.
Would that ease the merging of this PR? If so, I'll do that.
There was a problem hiding this comment.
See the commit originally introducing manual verification: 1e4c57f
There was a problem hiding this comment.
Ah, so it was added for Windows CE. So, it makes sense to just enable manual verification for Windows CE only. So, do away with DISABLE_SCHANNEL_MANUAL_VERIFY and just use _WIN32_WCE (which looks like the original behavior implemented).
There was a problem hiding this comment.
OK, I've removed DISABLE_SCHANNEL_MANUAL_VERIFY and used _WIN32_WCE as was originally written.
| #if !OLDER_THAN_WIN2K | ||
| #include <winnt.h> | ||
| #ifdef _MSC_VER | ||
| #pragma comment(lib, "ntdll.lib") |
There was a problem hiding this comment.
Thanks for working on this PR, but I guess reviewing it will be a lot easier once #7727 is settled. Not necessarily merged as it is right now as I don't think the discussion about ntdll is finished.
There was a problem hiding this comment.
I agree. That's why I made the other PR a couple of weeks ago, so there would be ample time to get that merged and then this reviewed.
Unfortunately we needed TLS 1.3 support on Windows and we couldn't wait any longer. We figured it would be better to share what we had immediately since Windows 11 will be released next week. And we didn't want other people wasting their time re-implementing the work we already did.
|
It seems like this is currently causing a lot of tests to fail on the various Windows CIs. This is definitely a blocker and needs to be fixed before we can consider this PR. |
…. Namely, enable "manual verify" in SChannel only on Windows CE.
|
To have a clearer picture of what this PR does, I'd suggest rebasing it on @jay's #7810, and thus dropping all version-detection-related extra bits from this patch. It'd be good to see why
|
I will once that PR has landed and when I (or someone else) lands a PR adding build version checking.
They don't really say that in that table, though. Unfortunately, as you've likely seen, the documentation is sparse. I remember reading it either in a Microsoft blog by a network-stack programmer or a comment on that blog by said programmer. Either way, you can confirm it yourself by passing the TLS_1_3 flag to the old Edit: @jay already tried this a year or so ago and got an error similar to what I described.
I'll fix that once the rebasing on the fixed version checking is done. Thanks! |
|
What's the current status of this work? It needs a rebase and force-push at the very least... |
|
I was planning on revisiting this Thursday or Friday this week. I'll start with a rebase on main ("master"), and then make the handful of changes requested throughout the thread. |
Yes, please do a fast rebase and merge commit. This will allow review |
|
Close in favor of the new PR with completed work, build on "main". |
|
after merging #8419, the next step is pehaps support msquic on schannel , see https://github.com/microsoft/msquic/blob/main/docs/Platforms.md |
Add SChannel TLS 1.3 support to curl / libcurl.
Has detection at runtime to enable / disable support depending on version of Windows.
Also, added a new define to disable optional code:
DISABLE_SCHANNEL_CLIENT_CERT(reduces compiled code size if that feature is not needed).A bit more work needs to be done before this is "merge-ready", but TLS 1.3 support is working.
This depends on this PR being merged: #7727
Remaining work: Implement "set_ssl_ciphers" for
SCH_CREDENTIALS. This is in the inverse of theSCHANNEL_CREDbehavior.Namely, we're disabling ciphers rather than enabling them. This will require a bit of thinking. I'll work on this this week, but if anyone wants to jump in and write that function, I'll be happy to accept the help.
Once that is implemented, everything else should be good to go. But I'll happily accept input on any of it.