Commit graph

2186 commits

Author SHA1 Message Date
Viktor Szakats
037ff984ff
or higher -> or greater 9 src 2026-06-13 00:09:22 +02:00
Viktor Szakats
46d858bc3b
or higher -> or greater 9 src 2026-06-13 00:09:22 +02:00
Viktor Szakats
c62c48ef44
and older -> or older 2026-06-13 00:09:05 +02:00
Viktor Szakats
9224d37408
and newer -> or newer 2026-06-13 00:09:05 +02:00
Viktor Szakats
44439068b8
and older -> or older 2026-06-13 00:09:05 +02:00
Viktor Szakats
e66bdb9941
and above -> or newer 2026-06-13 00:09:05 +02:00
Viktor Szakats
6ba2ab0741
or later -> newer (Windows version) 2026-06-13 00:09:05 +02:00
Viktor Szakats
a2e9dfa9f0
or older -> lower 2026-06-13 00:09:05 +02:00
Viktor Szakats
46c2cf51f7
at least -> higher 2026-06-13 00:09:05 +02:00
Viktor Szakats
7d02e46280
or newer -> higher 2026-06-13 00:09:05 +02:00
Viktor Szakats
1d5dc6d2f9
or later -> higher 2026-06-13 00:09:04 +02:00
Viktor Szakats
68a0bb1f50
or upper -> higher 2026-06-13 00:08:23 +02:00
Viktor Szakats
879a1514c3
socket: introduce SOCK_EAGAIN() and use it
To contain the logic of checking for both `EWOULDBLOCK` and/or `EAGAIN`
depending on platform/availability. Also to avoid checking for both if
they mapp to the same value, and to avoid PP guards around use.

This also ensures `EAGAIN` is consistently not checked on Windows, where
headers defined it, but `SOCKERRNO` never returns it, because curl maps
it to `WSAGetLastError()`.

If they map to the same value, checking them both in an `if` expression
trips GCC warning `-Wlogical-op` (the same way it triggers duplicate
case value error in `switch`).

Also:
- replace two `switch()` statements with the new macro.
- tests/server/sws: make two outliers use the new macro that were only
  checking for `EWOULDBLOCK` before this patch, in `connect_to()`.
- move variables to the left-side of expressions, where missing.
- rustls: use a variant of this macro that uses raw `EWOULDBLOCK`.
  Tried tracing it back to the origins, but I couldn't figure out if
  this is working as expected on all supported Windows versions in
  Rust. It seems to be using `GetLastError()`, according to
  https://docs.rs/system_error/0.2.0/system_error/, which would be
  probably incorrect.

Notes:
- it's probably a good idea to assign `SOCKERRNO` to a variable before
  passing it to this macro.

Cherry-picked from #21893

Closes #21992
2026-06-12 23:27:23 +02:00
Stefan Eissing
7d8c68adbe schannel: fix https proxy for client cert and certinfo
When schannel operates in front of a proxy, it needs to use the proxy
ssl configs, not the transfers ones. Choose the configs as it is done in
other TLS backends.

Prior to this change the client cert for the destination was mistakenly
also used as the client cert for the proxy.

Prior to this change the proxy server certificate info was mistakenly
saved as the destination cert info. However, if the destination was a
TLS connection, the real destination cert info would overwrite the
proxy cert info. libcurl currently does not support proxy server cert
info AFAICT (see discussion in #21986).

Closes https://github.com/curl/curl/pull/21986
2026-06-12 14:21:10 -04:00
Viktor Szakats
2a606c68fa
tidy-up: miscellaneous
- GHA/windows: drop redundant double-quotes.
- CMake/PickyWarnings: improve/shorten comment.
- INTERNALS: fix typo in LibreSSL release date.
- drop redundant parentheses from single variables and sole `#if`
  expressions.
- cf-ip-happy: fix missing space from error string.
- telnet: fix parentheses in commented PP code.
- lib1922: fix typo test output text.
- smbserver: unfold lines.
- smbserver: use f-string.
- smbserver: initialize binary string as b``.
- fix typos in comments.

Closes #21972
2026-06-11 19:48:07 +02:00
Viktor Szakats
97aed9c960
tidy-up: drop stray comparisons with literal zero
Drop from:
- strcmp, strcmpi, strncmp, memcmp, lstat, getrlimit, setrlimit, fseek,
  fstat
- autotools detection snippets.
- smooth-gtk-thread: simplify `!var != 0` expression.

Closes #21947
2026-06-10 15:15:54 +02:00
Viktor Szakats
2f3fa479dd
build: enable -Wformat-signedness, fix issues found
Adjust code to avoid `-Wformat-signedness` warnings, while making sure
that enums are always cast to a known type when passing them to `printf`
functions, to support compilers and compiler settings where enums are
not default-size signed ints.

- cast integers printed as hex to `unsigned`. (63 times, 20 of them in
  `mbedtls.c`)
- cast misc enums to `int` for printing. (31 times)
- cast `CURL_LOCK_DATA_*` enums to `int`. (4 times)
- cast `CURL_FORMADD_*` enums to `int`. (13 times)
- cast `CURLSHE_*` enums to `int`. (3 times)
- cast `CURLUE_*` enums to `int`. (33 times)
- cast `CURLMSG_*` enums to `int`. (6 times)
- cast `CURLE_*` enums to `int`. (~380 times)
- unit1675: fix mask.
  Follow-up to 7c34365cce #21879

Ref: #18343 (initial attempt)

Closes #20848
2026-06-10 15:14:08 +02:00
Stefan Eissing
f924489b25
ngtcp2: share common functionality
Share common functions/structs between ngtcp2 HTTP/3 and the proxy
version.

Fix bugs in proxy implementation when it comes to stream and pollset
handling and transfer lifetimes.

Curl_multi_xfer_sockbuf_borrow: work without multi

When a connection gets shutdown by a share, the easy handle used is
share->admin and it does not have a multi handle. In that case let
Curl_multi_xfer_sockbuf_borrow() allocate a buffer to be freed on
release.

This happens when a TLS filter sends its last notify through a HTTP/3
proxy tunnel.

Closes #21871
2026-06-10 13:28:05 +02:00
Viktor Szakats
014be82a66
tidy-up: drop redundant == NULL syntax
Where missed by checksrc.

Closes #21935
2026-06-09 14:37:36 +02:00
Viktor Szakats
59213abfb2
tidy-up: drop redundant != NULL syntax
Where missed by checksrc.

Closes #21932
2026-06-09 14:37:36 +02:00
Viktor Szakats
847aac066d
tidy-up: use uppercase TRUE/FALSE where missing
Keep it only in external API calls and C++ code.

Also:
- curlx/fopen: replace with `!!`.

Spotted by GitHub Code Quality in cf-socket.c.

Closes #21925
2026-06-09 12:52:08 +02:00
Viktor Szakats
952b04474c
tidy-up: miscellaneous
- badwords: replace stray synonyms with 'null-terminator'.
- tests/FILEFORMAT.md: tidy up feature descriptions.
- printf: replace stray `%i` masks with `%d` for consistency.
- pytest: add comments for empty excepts to try silencing GitHub CodeQL
  warnings.
- tool1394, unit1675: merge nested `if`s.
- dnscache: fix typo in comment.
- fix whitespace, indent and newlines.

Closes #21921
2026-06-09 11:07:55 +02:00
Stefan Eissing
d69bfad3fa
ssl native_ca_store: always reinit
Add bit `native_ca_store_opt` to keep the setting of
CURLOPT_(PROXY_)SSL_OPTIONS and use that to calculate every easy
transfer if a native CA store shall be used or not.

This avoids `native_ca_store` getting stuck on TRUE after being set
once.

Closes #21902
2026-06-08 13:53:54 +02:00
Vasiliy-Kkk
3b9f0972e2 schannel_verify: simplify CryptQueryObject use
- Specify that the content is base64 encoded, rather than rely on
  auto-detect.

- Remove unnecessary sanity check of the returned content type.

Closes https://github.com/curl/curl/pull/21760
2026-06-06 11:27:34 -04:00
Viktor Szakats
1b8f4dba28
tidy-up: drop stray casts for allocated pointers
Closes #21865
2026-06-05 12:24:01 +02:00
Viktor Szakats
2932b7f56f
gtls: minor fixes and improvements
- fix GnuTLS function name reference in `Curl_gtls_shared_creds_create()`
  error message.
  Spotted by GitHub Code Quality.
- unfold a line.
- in `Curl_gtls_verifyserver()`:
  - report the failure of `gnutls_x509_crt_import()`.
    Spotted by GitHub Code Quality.
  - fix a minor inconsistency in error strings.
  - drop redundant NULL checks for `config->issuercert`.

Closes #21850
2026-06-02 21:59:41 +02:00
Vasiliy-Kkk
a79467343f schannel: use fopen instead CreateFile
- Refactor CA file reading to use the typical fopen/fread instead of
  CreateFile/ReadFile.

Closes https://github.com/curl/curl/pull/21773
2026-06-02 13:58:21 -04:00
Joshua Rogers
be6c4ee7fa
gtls: verify OCSP response signature in gtls_verify_ocsp_status
Since aeb1a281ca ("gtls: fix OCSP stapling management"), the function
parses the stapled OCSP response and reads the certificate status via
gnutls_ocsp_resp_get_single(), but never calls gnutls_ocsp_resp_verify()
or gnutls_ocsp_resp_verify_direct(). A response with a forged or
corrupted signature is accepted without question.

Fix by calling gnutls_ocsp_resp_verify() against the trust list obtained
from the session credentials immediately after gnutls_ocsp_resp_import().
This handles both directly-signed responses and delegated OCSP responders
without requiring the issuer certificate to be present in the peer chain.

The missing check only affects the CURLOPT_SSL_VERIFYSTATUS code path
when CURLOPT_SSL_VERIFYPEER is disabled. With peer verification enabled,
gnutls_certificate_verify_peers2() independently catches the invalid
response via GNUTLS_CERT_INVALID_OCSP_STATUS before
gtls_verify_ocsp_status() is reached. As a result, no attack is possible
that is not already trivially achievable without OCSP stapling when peer
verification is off. This is a correctness and consistency fix, not a
security vulnerability.

Reported-by: Joshua Rogers

Closes #21677
2026-06-02 13:30:35 +02:00
Stefan Eissing
31cb54e1fa
cfilters: remove close method
closing a filter chain and reconnecting it again is a complication
that only the HTTP/1.x proxy filter used. Remove it from all filters.

Instead, a filter can return CURLE_AGAIN during the connect phase
and the cf-setup filter will tear down all "sub filters" and restart
over.

With this, a filter never resets to the initial phase but progresses
through connect -> connected -> shutdown -> destroy once.

Closes #21831
2026-06-02 08:27:00 +02:00
Stefan Eissing
d3391229b0
vtls_config: adjust to origin
When a transfer goes against another origin than the initial one, do not
add the following to the ssl configuration: client cert, client key, srp
user/pass, pinned key.

Closes #21695
2026-06-01 09:39:17 +02:00
Viktor Szakats
f1a6f190a6
badwords: prefer 'workaround' (without hyphen)
Closes #21807
2026-05-31 22:05:54 +02:00
Viktor Szakats
59320082b0
tidy-up: apply clang-format fixes
To lib, vtls/vauth, vtls/vquic, lib/vtls.

Also:
- unit3400: drop redundant `(void)arg`.
  Follow-up to e78b1b3ecc #21153
- fix comment typos.

Closes #21786
2026-05-28 00:05:47 +02:00
Viktor Szakats
40f2da6ec3
vtls: more large buffer support and error checks for SHA-256
- gnutls: support 4GiB+ SHA-256 digest inputs.
- openssl: check success of low-level update/finish digest calls.
- openssl: pass NULL to `EVP_DigestFinal_ex()` instead of discarding
  returned value.
- wolfssl: support 4GiB+ SHA-256 digest inputs.
- wolfssl: check success of low-level update/finish digest calls.
- sync and tidy up argument names in low-level sha256_sum functions.

Closes #21771
2026-05-27 16:57:39 +02:00
Viktor Szakats
a1baacc670
schannel: check schannel_sha256sum() success, and more
Also:
- support 4GiB+ SHA-256 digest inputs.
- check `CryptGetHashParam()` output size.
- avoid overwriting existing digest when new digest calculation fails.
- avoid adding digest hash element on failure.

Closes #21739
2026-05-27 16:57:38 +02:00
Viktor Szakats
7bcf34672d
vtls_spack: drop redundant macro fallbacks
For `UINT16_MAX` and `UINT32_MAX`. They are used in other sources
without this fallback.

Closes #21768
2026-05-27 16:53:57 +02:00
Viktor Szakats
7e1001bcd6
tidy-up: miscellaneous
- H3 proxy: re-sync code with original source `curl_ngtcp2.c` to reduce
  differences, and to apply missed minor fixes. Also apply clang-format.
  Drop redundant `#undef`s, casts, `#endif` comments, includes, drop
  intermediate variables, sync include and macro order.
  Follow-up to e78b1b3ecc #21153
- INSTALL-CMAKE.md: move `CURL_ENABLE_SMB` to the enable section.
- tests/http/env: rename `tcpdmp` to `tcpdump` to match object variable.
- mbedtls: drop incorrect `mbedTLS 4+` comments.
  (features are also supported by 3+, meaning it's always supported.)
- lib1648: rename a variable to match purpose.
- CIPHERS.md: alpha-sort link list.
- replace rare `X''` hex markup with `0x`.
- `IP v4/6` -> `IPv4/6`.
- 'version X.Y' -> 'vX.Y', where sensible.
- 'VX.Y' -> 'vX.Y', where sensible.
- fix indents, casing, newlines, typos.

Closes #21772
2026-05-27 16:53:57 +02:00
Daniel Stenberg
efdf733bae
gtls: use the correct return code in trace output
Instead of using a hard-coded zero.

Spotted by Copilot

Closes #21766
2026-05-27 09:38:39 +02:00
Joshua Rogers
f21b5d4e66
gtls: fix ignored return and uninitialized status in OCSP check
gnutls_ocsp_resp_get_single() was called with (void) discarding its
return value, so a failure (e.g. an OCSP response with no
SingleResponse entries) went undetected.  The following switch() then
read an uninitialized gnutls_ocsp_cert_status_t, which is undefined
behaviour and could yield GNUTLS_OCSP_CERT_GOOD (0) depending on
stack contents, causing gtls_verify_ocsp_status to return CURLE_OK for
a response that was never successfully parsed.

Fix by initializing status to GNUTLS_OCSP_CERT_UNKNOWN and treating a
negative return from gnutls_ocsp_resp_get_single as an error.

Closes #21679
2026-05-27 09:01:00 +02:00
Aritra Basu
e78b1b3ecc
HTTP/3: add proxy CONNECT and MASQUE CONNECT-UDP support (ngtcp2 QUIC)
This patch adds two major proxy capabilities to curl (ngtcp2 QUIC):
- HTTP/3 Proxy CONNECT: Tunnel HTTP/1.1 or HTTP/2 traffic through an
  HTTPS proxy that speaks HTTP/3 (QUIC) using the standard CONNECT
  method over an HTTP/3 connection.
- MASQUE CONNECT-UDP: Tunnel HTTP/3 (QUIC) traffic through an HTTP
  proxy (speaking HTTP/1.1, HTTP/2, or HTTP/3) using the extended
  CONNECT method with the CONNECT-UDP protocol (RFC9297 & RFC9298).

Public API additions:
- `CURLPROXY_HTTPS3`: new proxy type constant for HTTP/3 proxy
- `--proxy-http3`: new CLI flag to negotiate HTTP/3 with HTTPS proxy

The implementation adds two new filters:
- `H3-PROXY` - enables negotiating HTTP/3 (QUIC) to the proxy and
  running CONNECT/CONNECT-UDP through that proxy transport.
- `CAPSULE` - dedicated filter inserted between QUIC transport and
  HTTP-PROXY to handle datagram capsule encapsulation/decapsulation.

Here is how the curl filter chaining looks in different scenarios:
- HTTP/3 Proxy CONNECT (tunneling TCP protocols over QUIC proxy):
  conn -> HTTP/1.1 or HTTP/2  -> SSL -> HTTP-PROXY ->
                                 H3-PROXY -> HAPPY-EYEBALLS -> UDP
- MASQUE CONNECT-UDP (tunneling QUIC over any proxy):
  conn -> HTTP/3 -> CAPSULE -> HTTP-PROXY -> H3-PROXY ->
                               HAPPY-EYEBALLS -> UDP
  conn -> HTTP/3 -> CAPSULE -> HTTP-PROXY -> H1-PROXY or H2-PROXY ->
                               SSL -> HAPPY-EYEBALLS -> TCP

- Both features currently require the ngtcp2 QUIC backend.
- Both features are experimental (disabled by default). Enable with
  `--enable-proxy-http3`(autotools) or `-DUSE_PROXY_HTTP3=ON`(CMake).

Tests:
- tests/unit/unit3400.c: Unit tests for capsule protocol encode/decode
- tests/http/test_60_h3_proxy.py: Comprehensive pytest integration suite
- tests/http/testenv/h2o.py: Managing h2o instances with HTTP/1.1, HTTP/2,
  and HTTP/3 (QUIC) listeners, proxy.connect and proxy.connect-udp enabled.

References:
  RFC 9297 - HTTP Datagrams and the Capsule Protocol
  RFC 9298 - Proxying UDP in HTTP
  RFC 9000 §16 — Variable-Length Integer Encoding

Signed-off-by: Aritra Basu <aritrbas+gh@cisco.com>

Closes #21153
2026-05-27 08:49:53 +02:00
Stefan Eissing
f27233e984
GnuTLS: require 3.7.2 for earlydata
Since all API features we need for TLSv1.3 earlydata support do exist
only from version 3.7.2 onwards, make that the minimal version required.

Fixes #21750
Reported-by: Johannes Schlatow
Closes #21751
2026-05-26 13:41:21 +02:00
Joshua Rogers
fc90bdbaf9 schannel: error on TLS 1.3-only with cipher list
The legacy SCHANNEL_CRED path cannot negotiate TLS 1.3. When TLS 1.3
is the only enabled protocol and a cipher list is set, fail instead of
silently downgrading to TLS 1.2.

Fixes https://github.com/curl/curl/issues/21702
Closes https://github.com/curl/curl/pull/21725
2026-05-22 11:22:15 -04:00
Viktor Szakats
bcd0497c81
tidy-up: use curlx_safefree()
Closes #21700
2026-05-21 01:31:03 +02:00
Joshua Rogers
cce4d3b0ed schannel: fix revoke_best_effort setting for proxy
- Fix revoke_best_effort reading wrong ssl config.

Prior to this change the revoke_best_effort setting for the proxy was
wrongly ignored in favor of the same setting for the destination host.

In other words, CURLSSLOPT_REVOKE_BEST_EFFORT set via
CURLOPT_PROXY_SSL_OPTIONS did not apply to the proxy and
CURLSSLOPT_REVOKE_BEST_EFFORT set via CURLOPT_SSL_OPTIONS wrongly
applied to the proxy.

Closes https://github.com/curl/curl/pull/21683
2026-05-20 13:51:35 -04:00
Viktor Szakats
b3f76b21c9
tidy-up: miscellaneous
- fix typos and wording in documentation and comments.
- KNOWN_BUGS: merge duplicate H1 section.
- test_10_proxy: delete stray expressions.
- Perl: `while()` -> `while(1)`.
- Perl: fix indent, whitespace, drop redundant quotes and parentheses.
- fix casing: URL, SSL, Windows.
- badwords: readd `threadsafe`, add `well-known` (and fix it).
- replace `WinXP` -> `Windows XP` to match other uses.

Closes #21646
2026-05-20 00:50:43 +02:00
Joshua Rogers
7541ae569d
tls: fix incomplete mTLS config in conn reuse and session cache
cert_type, key, key_type, key_passwd and key_blob lived in
ssl_config_data but not in ssl_primary_config, so they were invisible to
match_ssl_primary_config() and to the TLS session cache peer key.

Two easy handles sharing a connection pool could reuse each other's
authenticated connections when they differed only on SSLKEY, SSLKEYTYPE,
KEYPASSWD, SSLCERTTYPE or SSLKEYBLOB. The second handle would silently
inherit the first handle's authenticated identity.

Promote all five fields into ssl_primary_config so the conn-reuse
predicate and session cache key cover the complete client credential
set. Also replace the fixed ":CCERT" session cache marker with the
actual clientcert path so sessions are not shared across different
client certificates.

Verified by test 3303 and 3304

Reported-By: Joshua Rogers (AISLE Research)
Closes #21667
2026-05-20 00:02:33 +02:00
Viktor Szakats
000de81fb1
tidy-up: rename more CURLcode variables to result
Follow-up to 885b553545 #21348

Closes #21676
2026-05-19 16:55:45 +02:00
Joshua Rogers
81da4ee249
vtls: use Curl_safecmp for CRLfile and pinned_key comparison
Both are filesystem paths (or case-sensitive hash strings for
pinned_key). curl_strequal is case-insensitive and would treat
/etc/ssl/Crl.pem and /etc/ssl/crl.pem as the same file, unlike the other
path fields (CApath, CAfile, issuercert, clientcert) which already use
Curl_safecmp.

Closes #21668
2026-05-19 15:10:47 +02:00
Mark Esler
8a86fa13f3
vtls_scache: include signature_algorithms in the SSL peer cache key
Curl_ssl_peer_key_make() omitted ssl->signature_algorithms, although
match_ssl_primary_config() compares the field. Two handles differing
only in CURLOPT_SSL_SIGNATURE_ALGORITHMS therefore shared a peer key and
could resume each other's sessions across a shared CURLSH SSL session
cache.

Add :SIGALGS-%s next to the other ssl_primary_config fields.

Closes #21651
2026-05-18 13:59:11 +02:00
Viktor Szakats
3f8f725d97
schannel: enforce Extended Key Usage for custom CA roots
Reported-by: Joshua Rogers (Aisle Research)

Closes #21629
2026-05-16 11:55:59 +02:00
Sergio Correia
61d59c9e39
x509asn1: fix DH public key parameter extraction
The dh(g) parameter was read from param->beg instead of from the
cursor p returned by parsing dh(p). This caused dh(g) to always
report the same value as dh(p) when inspecting DH certificates
via CURLOPT_CERTINFO on non-OpenSSL backends.

The DSA branch correctly advances the cursor; the DH branch lost
this during what appears to be a copy-paste.

Add unit1676 to verify that dh(p) and dh(g) report distinct values
using a hand-crafted minimal DER certificate.

Assisted by: Claude Opus 4.6
Signed-off-by: Sergio Correia <scorreia@redhat.com>
Closes #21595
2026-05-16 01:06:56 +02:00