Repository navigation
Restore Windows SSPI for the rustls and windows-static-ssl backends - #667
Open
ns-ylambert wants to merge 2 commits into
Open
ns-ylambert wants to merge 2 commits into
ns-ylambert wants to merge 2 commits into
Conversation
The upstream `spnego` feature defined `USE_SPNEGO` unconditionally on all platforms, including Windows. On Windows, `USE_SPNEGO` activates code in `http_negotiate.c` that references `struct negotiatedata::context` (a field only defined when `USE_WINDOWS_SSPI` is present). Under the `rustls` or `windows-static-ssl` TLS backends, `USE_WINDOWS_SSPI` is not defined, causing `C2039 'context' is not a member of 'negotiatedata'` errors. Fix: guard the `USE_SPNEGO` define to non-Windows only. On Windows, `curl_setup.h` auto-defines `USE_SPNEGO` from `USE_WINDOWS_SSPI` whenever that is set. `http_negotiate.c` is still compiled on Windows when `spnego` is requested (it contains valid stub paths for non-SSPI builds), but without `USE_SPNEGO` the `context`-field access at line 203 is inside a dead `#ifdef` block. `spnego_sspi.c` genuinely requires `USE_WINDOWS_SSPI` to compile (it is a Windows-SSPI-specific file). Introduce `windows_sspi` — true when `ssl` / Schannel is the active backend on Windows — and gate `spnego_sspi.c` exclusively on it. Summary of SPNEGO source gating after this commit: - `USE_SPNEGO` define: non-Windows `spnego` only. - `http_negotiate.c`: `windows_sspi` OR `spnego` (any platform/backend). - `spnego_sspi.c`: `windows_sspi` only. Also removes the duplicate `http_negotiate.c` / `spnego_sspi.c` / `vauth.c` entries from the Schannel per-backend block (`vauth.c` is already in the unconditional base source set).
The SSPI infrastructure (`curl_sspi.c`, `socks_sspi.c`, `vauth/krb5_sspi.c`) and `USE_WINDOWS_SSPI` are compiled only under `feature = "ssl"` on Windows, which also enables Schannel. A `rustls` (curl+rustls-ffi) or `windows-static-ssl` (curl+OpenSSL) build therefore silently loses libcurl's SSPI-backed integrated Windows authentication (NTLM-SSO / Negotiate-SSO), even though SSPI is TLS-backend-independent at the C level. Add `USE_WINDOWS_SSPI` and the same three SSPI infrastructure files to the `rustls` / `windows-static-ssl` branches on Windows, without `USE_SCHANNEL` or the Schannel-only sources (`schannel.c`, `schannel_verify.c`). Also widen the `windows_sspi` guard (introduced by the companion "fix spnego + rustls" commit) from `ssl`-only to cover both `rustls` and `windows-static-ssl`, so the shared SPNEGO sources (`http_negotiate.c`, `vauth/spnego_sspi.c`) are compiled for all three Windows TLS backends (OpenSSL / Rustls / Schannel).
ns-ylambert
force-pushed
the
fix-sspi-non-schannel
branch
from
October 12, 2026 18:01
307eb3d to
e18f765
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
libcurl's Windows SSPI infrastructure — the machinery for integrated Windows auth (NTLM-SSO, Negotiate/Kerberos-SSO) — is currently compiled only under
feature = "ssl"on Windows (which also enables Schannel). Users onrustls(curl+rustls-ffi) orwindows-static-ssl(curl+OpenSSL) silently lose that capability, even though SSPI is TLS-backend-independent at the C level.Additionally, the
spnegofeature is broken on Windows for non-Schannel backends: the upstreamUSE_SPNEGOdefine is unconditional on all platforms and activates code inhttp_negotiate.creferencingstruct negotiatedata::context— a field only defined whenUSE_WINDOWS_SSPIis set. Underrustlsorwindows-static-ssl(noUSE_WINDOWS_SSPI), this fails to compile withC2039 'context' is not a member of 'negotiatedata'.This PR fixes both.
What lands
Two commits:
curl-sys: fix spnego + rustls compile error on Windows: guardsUSE_SPNEGOto non-Windows only (on Windows,curl_setup.hauto-defines it fromUSE_WINDOWS_SSPIwhen that's set). Refactors SPNEGO source gating sohttp_negotiate.candspnego_sspi.ccompile correctly regardless of TLS backend. Removes duplicate file entries from the Schannel per-backend block.curl-sys: compile Windows SSPI in the rustls/windows-static-ssl branches: addsUSE_WINDOWS_SSPI+ the three SSPI infrastructure files to therustlsandwindows-static-sslbranches, without pulling in Schannel-specific sources. Widens thewindows_sspiguard to cover all three Windows TLS backends.Verification
cargo check -p curl-sys --features static-curl,rustls,spnego --target x86_64-pc-windows-msvc: succeeds on this PR; fails with C2039 onorigin/main.cargo check -p curl-sys --features static-curl,rustls --target x86_64-pc-windows-msvc: compiles cleanly with SSPI now included.cargo check -p curl-sys --features static-curl --target x86_64-pc-windows-msvc(default Schannel): unchanged behavior.Compile-check matrix
mainstatic-curl,rustls,spnegostatic-curl,rustlsstatic-curl,windows-static-ssl(behind #666)static-curl(default Schannel)¹ CI mode = what
ci/run.shdoes with this combination onTest (win64).test-executeruns the test binaries,test-compileis--no-run,—means this combo isn't directly exercised by CI onorigin/mainbut compiles when checked locally.² Baseline behavior on
origin/main: theC1083 opensslv.hfailurestatic-curl,windows-static-sslhits without this fix is orthogonal to this PR's concern; it's what #666 (fix-windows-static-ssl) addresses. Once #666 merges, thewindows-static-sslrow would gain a proper CI signal via thewin64-static-sslmatrix entry.Note on CI coverage of the C2039 fix
ci/run.shcurrently does not exercise--features rustls,static-curl,spnegoon any target. Commit307eb3d's SSPI-beside-rustls addition IS exercised by the existingTest (win64)--features rustls,static-curlinvocation (SSPI files compile as part of that build now), but commit351987c's specific C2039 fix has no CI-executed guard. Addingaround line 34 of
ci/run.shwould promote the C2039 fix from a locally-verified reproducer to a CI-executed guard against future regressions. Windows-msvc-gated because the C2039 bug is Windows-specific. Enablingspnegoon the Linux docker targets would pull in GSSAPI sources that needlibkrb5-dev, a build dep the current Linux docker images don't install. Kept out of this PR to keep the diff minimal; happy to add if desired.Related
spnegofeature. SSPI was always the intended Windows integration; the C2039 regression this PR fixes accumulated later when therustls(Add experimental support for rustls #374) andwindows-static-ssl(Adding the possibility to use windows openssl backend instead of schannel #466) backends landed without keeping SSPI wiring in sync.ftp.candbufref.c(unrelated to SPNEGO/SSPI) to fix a parallel-buildC1083: Permission deniedrace, which this PR does not touch. It does not gateUSE_SPNEGOby platform, so it does not itself fix the C2039 bug this PR addresses. The two PRs are complementary; a merge conflict is likely on the SPNEGO/SSPI block regardless of order.spnegobuild ergonomics (missinglibgssat build time); this PR fixes the Windows/SSPI side. It remains open for the Linux/GSSAPI side.windows-static-ssl+ SSPI code path requires Fix and cover thewindows-static-sslfeature (curl+OpenSSL on Windows) #666 to land first. Onorigin/main, no matrix entry exercises--features windows-static-ssl; commit 2's addition to that branch is compiled locally but not by CI on this PR. Once merged, this PR'swindows-static-sslchanges gain end-to-end coverage from thewin64-static-sslmatrix entry.rustls/windows-static-sslbackends: behavior gap not tracked as a public issue yet.