[packages/curl] Rel 2. Backport upstream fixes for pending curl advisories

arekm arekm at pld-linux.org
Tue Nov 3 14:06:03 CET 2026


commit 91253590271094acdd8c7b6196a6e05d4a4a9ebc
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Nov 3 14:05:33 2026 +0100

    Rel 2. Backport upstream fixes for pending curl advisories
    
    Fixes CVE-2026-111954, CVE-2026-111952, CVE-2026-111951,
    CVE-2026-111950, CVE-2026-111878, CVE-2026-111483, CVE-2026-111482,
    CVE-2026-111481.
    
    Also fix the 8.22.0 regression reusing idle connections with unread
    input (upstream #23621).

 curl-CVE-2026-111481.patch          | 125 +++++
 curl-CVE-2026-111482.patch          | 163 +++++++
 curl-CVE-2026-111483.patch          | 363 +++++++++++++++
 curl-CVE-2026-111878.patch          | 895 ++++++++++++++++++++++++++++++++++++
 curl-CVE-2026-111950.patch          |  54 +++
 curl-CVE-2026-111951.patch          | 116 +++++
 curl-CVE-2026-111952.patch          |  32 ++
 curl-CVE-2026-111954.patch          |  20 +
 curl-conn-reuse-pending-input.patch | 129 ++++++
 curl.spec                           |  36 +-
 10 files changed, 1924 insertions(+), 9 deletions(-)
---
diff --git a/curl.spec b/curl.spec
index 12dda1c..4e32db5 100644
--- a/curl.spec
+++ b/curl.spec
@@ -24,13 +24,22 @@ Summary(ru.UTF-8):	Утилита для получения файлов с се
 Summary(uk.UTF-8):	Утиліта для отримання файлів з серверів FTP, HTTP та інших
 Name:		curl
 Version:	8.23.0
-Release:	1
+Release:	2
 License:	MIT-like
 Group:		Applications/Networking
 Source0:	https://curl.se/download/%{name}-%{version}.tar.xz
 # Source0-md5:	f28835fef6d894c0559d5dbc0c071760
 Patch0:		%{name}-ac.patch
 Patch1:		%{name}-krb5flags.patch
+Patch2:		%{name}-CVE-2026-111481.patch
+Patch3:		%{name}-conn-reuse-pending-input.patch
+Patch4:		%{name}-CVE-2026-111482.patch
+Patch5:		%{name}-CVE-2026-111483.patch
+Patch6:		%{name}-CVE-2026-111878.patch
+Patch7:		%{name}-CVE-2026-111952.patch
+Patch8:		%{name}-CVE-2026-111954.patch
+Patch9:		%{name}-CVE-2026-111951.patch
+Patch10:	%{name}-CVE-2026-111950.patch
 URL:		https://curl.se/
 BuildRequires:	autoconf >= 2.57
 BuildRequires:	automake
@@ -42,7 +51,6 @@ BuildRequires:	libidn2-devel
 BuildRequires:	libpsl-devel
 %{?with_ssh:BuildRequires:	libssh2-devel >= 1.11.1}
 BuildRequires:	libtool
-BuildRequires:	nettle-devel
 %{?with_http2:BuildRequires:	nghttp2-devel >= 1.15.0}
 %{?with_http3:BuildRequires:	nghttp3-devel}
 # with gnutls or openssl crypto, conforming to chosen curl crypto library
@@ -55,9 +63,10 @@ BuildRequires:	rpm-build >= 4.6
 BuildRequires:	rpmbuild(macros) >= 1.527
 %if %{with ssl}
 %if %{with gnutls}
-BuildRequires:	gnutls-devel >= 3.1.10
+BuildRequires:	gnutls-devel >= 3.6.5
+BuildRequires:	nettle-devel
 %else
-BuildRequires:	openssl-devel >= 1.0.1
+BuildRequires:	openssl-devel >= 3.0.0
 %endif
 %endif
 BuildRequires:	tar >= 1:1.22
@@ -122,12 +131,12 @@ Summary:	curl library
 Summary(pl.UTF-8):	Biblioteka curl
 Group:		Libraries
 %{?with_ares:Requires:	c-ares >= 1.17.0}
-%{?with_gnutls:Requires:	gnutls-libs >= 3.1.10}
+%{?with_gnutls:Requires:	gnutls-libs >= 3.6.5}
 %{?with_ssh:Requires:	libssh2%{?_isa} >= 1.11.1}
 %{?with_http2:Requires:	nghttp2-libs >= 1.15.0}
-%if %{with ssl} && %{without gnutls}
 Requires:	libbrotli%{?_isa} >= 1.0.0
-Requires:	openssl%{?_isa} >= 1.0.1
+%if %{with ssl} && %{without gnutls}
+Requires:	openssl%{?_isa} >= 3.0.0
 %endif
 Suggests:	ca-certificates
 Conflicts:	ca-certificates < 20080809-4
@@ -157,9 +166,9 @@ Requires:	libpsl-devel%{?_isa}
 %{?with_ldap:Requires:	openldap-devel%{?_isa}}
 %if %{with ssl}
 %if %{with gnutls}
-Requires:	gnutls-devel%{?_isa} >= 3.1.10
+Requires:	gnutls-devel%{?_isa} >= 3.6.5
 %else
-Requires:	openssl-devel%{?_isa} >= 0.9.7c
+Requires:	openssl-devel%{?_isa} >= 3.0.0
 %endif
 %endif
 Requires:	zlib-devel%{?_isa}
@@ -241,6 +250,15 @@ Dopełnianianie parametrów w ZSH dla polecenia curl.
 %setup -q
 %patch -P0 -p1
 %patch -P1 -p1
+%patch -P2 -p1
+%patch -P3 -p1
+%patch -P4 -p1
+%patch -P5 -p1
+%patch -P6 -p1
+%patch -P7 -p1
+%patch -P8 -p1
+%patch -P9 -p1
+%patch -P10 -p1
 
 %{__rm} m4/lt*.m4 m4/libtool.m4
 
diff --git a/curl-CVE-2026-111481.patch b/curl-CVE-2026-111481.patch
new file mode 100644
index 0000000..d599f5f
--- /dev/null
+++ b/curl-CVE-2026-111481.patch
@@ -0,0 +1,125 @@
+CVE-2026-111481: server-set cookie still aborts cookie jar load
+https://github.com/curl/curl/commit/7d64440abba37e3d8039fe663d3edc84f582ce92
+
+diff --git a/lib/cookie.c b/lib/cookie.c
+index cea93d6..04ce59c 100644
+--- a/lib/cookie.c
++++ b/lib/cookie.c
+@@ -38,6 +38,7 @@
+ #include "curl_memrchr.h"
+ #include "parsedate.h"
+ #include "curlx/strdup.h"
++#include "curlx/dynbuf.h"
+ #include "llist.h"
+ #include "curlx/strparse.h"
+ 
+@@ -1169,9 +1170,11 @@ static CURLcode cookie_load(struct Curl_easy *data, const char *file,
+   if(fp) {
+     struct dynbuf buf;
+     bool eof = FALSE;
+-    /* accept a little longer lines so that a full cookie fits and does not
+-       abort the file read */
+-    curlx_dyn_init(&buf, MAX_COOKIE_LINE + 48);
++    /* get_netscape_format() uses curl_maprintf(), which returns at most
++       DYN_APRINTF - 1 bytes. cookie_output() adds a newline (CRLF on Windows),
++       and this dynbuf needs one more byte for its null-terminator. This is a
++       cap, not an allocation. */
++    curlx_dyn_init(&buf, DYN_APRINTF + 2);
+     do {
+       result = Curl_get_line(&buf, fp, &eof);
+       if(!result) {
+diff --git a/tests/data/test1902 b/tests/data/test1902
+index 0dee174..2e17f14 100644
+--- a/tests/data/test1902
++++ b/tests/data/test1902
+@@ -3,6 +3,7 @@
+ <info>
+ <keywords>
+ cookies
++cookiejar
+ libtest
+ </keywords>
+ </info>
+@@ -11,7 +12,7 @@ libtest
+ <client>
+ 
+ <name>
+-set COOKIEFILE and COOKIEJAR but make no transfer
++reload a long cookie jar line without a transfer
+ </name>
+ <features>
+ cookies
+@@ -25,6 +26,7 @@ cookies
+ # https://curl.se/docs/http-cookies.html
+ # This file was generated by libcurl! Edit at your own risk.
+ 
++example.com	FALSE	/%repeat[6000 x q]%	FALSE	0	long	value
+ example.com	FALSE	/	FALSE	0	has_js	1
+ </file>
+ </client>
+@@ -36,6 +38,7 @@ example.com	FALSE	/	FALSE	0	has_js	1
+ # https://curl.se/docs/http-cookies.html
+ # This file was generated by libcurl! Edit at your own risk.
+ 
++example.com	FALSE	/%repeat[6000 x q]%	FALSE	0	long	value
+ example.com	FALSE	/	FALSE	0	has_js	1
+ </file>
+ </verify>
+diff --git a/tests/libtest/lib1902.c b/tests/libtest/lib1902.c
+index b2ceb3d..4af6249 100644
+--- a/tests/libtest/lib1902.c
++++ b/tests/libtest/lib1902.c
+@@ -27,19 +27,48 @@ static CURLcode test_lib1902(const char *URL)
+ {
+   CURLcode result = CURLE_OK;
+   CURL *curl;
++  struct curl_slist *cookies = NULL;
++  struct curl_slist *cookie;
++  bool long_found = FALSE;
++  bool short_found = FALSE;
++  size_t count = 0;
+ 
+   curl_global_init(CURL_GLOBAL_ALL);
+ 
+   curl = curl_easy_init();
+-  if(curl) {
+-    easy_setopt(curl, CURLOPT_COOKIEFILE, URL);
+-    easy_setopt(curl, CURLOPT_COOKIEJAR, URL);
++  if(!curl) {
++    result = TEST_ERR_EASY_INIT;
++    goto test_cleanup;
++  }
++  easy_setopt(curl, CURLOPT_COOKIEFILE, URL);
++  easy_setopt(curl, CURLOPT_COOKIEJAR, URL);
++
++  /* The original case: no transfer means no cookie jar write. */
++  curl_easy_cleanup(curl);
++  curl = curl_easy_init();
++  if(!curl) {
++    result = TEST_ERR_EASY_INIT;
++    goto test_cleanup;
++  }
+ 
+-    /* Do not perform any actual network operation,
+-       the issue occur when not calling curl.*perform */
++  /* Explicitly reload the same jar, also without starting a transfer. */
++  easy_setopt(curl, CURLOPT_COOKIEFILE, URL);
++  easy_setopt(curl, CURLOPT_COOKIELIST, "RELOAD");
++  result = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
++  if(result)
++    goto test_cleanup;
++  for(cookie = cookies; cookie; cookie = cookie->next) {
++    if(strstr(cookie->data, "\tlong\tvalue"))
++      long_found = strlen(cookie->data) > 5048;
++    if(strstr(cookie->data, "\thas_js\t1"))
++      short_found = TRUE;
++    count++;
+   }
++  if(count != 2 || !long_found || !short_found)
++    result = TEST_ERR_FAILURE;
+ 
+ test_cleanup:
++  curl_slist_free_all(cookies);
+   curl_easy_cleanup(curl);
+   curl_global_cleanup();
+   return result;
diff --git a/curl-CVE-2026-111482.patch b/curl-CVE-2026-111482.patch
new file mode 100644
index 0000000..e18ac75
--- /dev/null
+++ b/curl-CVE-2026-111482.patch
@@ -0,0 +1,163 @@
+CVE-2026-111482: libssh2 known hosts prefix match
+https://github.com/curl/curl/commit/a978dfa5e3acfa6c0c56fac3b8899b354b15b00f
+
+diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c
+index 1a05eaa..12f8352 100644
+--- a/lib/vssh/libssh2.c
++++ b/lib/vssh/libssh2.c
+@@ -679,7 +679,8 @@ static CURLcode ssh_force_knownhost_key_type(struct Curl_easy *data,
+             if(!curlx_str_number(&p, &port, 0xffff) &&
+                (kh_name_end && (port == conn->origin->port))) {
+               kh_name_size = strlen(store->name) - 1 - strlen(kh_name_end);
+-              if(!strncmp(store->name + 1, conn->origin->hostname,
++              if((kh_name_size == strlen(conn->origin->hostname)) &&
++                 !strncmp(store->name + 1, conn->origin->hostname,
+                           kh_name_size)) {
+                 found = TRUE;
+                 break;
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index 0c90ccf..d6d110d 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -24,6 +24,8 @@
+ 
+ # scripts used in test cases
+ TESTSCRIPTS = \
++  test745.pl  \
++  test971.pl  \
+   test1119.pl \
+   test1135.pl \
+   test1139.pl \
+@@ -41,8 +43,7 @@ TESTSCRIPTS = \
+   test1488.pl \
+   test1544.pl \
+   test1707.pl \
+-  test745.pl  \
+-  test971.pl
++  test3990.pl
+ 
+ EXTRA_DIST =         \
+   CMakeLists.txt     \
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 0f4ce61..c96880f 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -2139,6 +2139,8 @@ TESTCASES = \
+   test3595 \
+   test3596 \
+   test3611 \
++  test3990 \
++  test3991 \
+   test4000 \
+   test4001 \
+   test4039 \
+diff --git a/tests/data/test3990 b/tests/data/test3990
+new file mode 100644
+index 0000000..f67b532
+--- /dev/null
++++ b/tests/data/test3990
+@@ -0,0 +1,38 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++SFTP
++known_hosts
++libssh2
++</keywords>
++</info>
++<reply>
++<data>
++Test data
++</data>
++</reply>
++<client>
++<server>
++sftp
++</server>
++<features>
++sftp
++libssh2
++</features>
++<precheck>
++%PERL %SRCDIR/test3990.pl %LOGDIR/server/curl_host_key.pub %LOGDIR/known%TESTNUMBER "[127.0.0]:%SSHPORT" "[%HOSTIP]:%SSHPORT"
++</precheck>
++<name>
++SFTP known_hosts, [host]:port entry for a prefix of the host first
++</name>
++<command>
++--knownhosts %LOGDIR/known%TESTNUMBER --key %LOGDIR/server/curl_client_key --pubkey %LOGDIR/server/curl_client_key.pub -u %USER: sftp://%HOSTIP:%SSHPORT%SFTP_PWD/%LOGDIR/file%TESTNUMBER.txt
++</command>
++<file name="%LOGDIR/file%TESTNUMBER.txt">
++Test data
++</file>
++</client>
++<verify>
++</verify>
++</testcase>
+diff --git a/tests/data/test3991 b/tests/data/test3991
+new file mode 100644
+index 0000000..d3f2f9c
+--- /dev/null
++++ b/tests/data/test3991
+@@ -0,0 +1,38 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++SFTP
++known_hosts
++libssh2
++</keywords>
++</info>
++<reply>
++<data>
++Test data
++</data>
++</reply>
++<client>
++<server>
++sftp
++</server>
++<features>
++sftp
++libssh2
++</features>
++<precheck>
++%PERL %SRCDIR/test3990.pl %LOGDIR/server/curl_host_key.pub %LOGDIR/known%TESTNUMBER "[%HOSTIP.2]:%SSHPORT" "[%HOSTIP]:%SSHPORT"
++</precheck>
++<name>
++SFTP known_hosts, [host]:port entry for another host first
++</name>
++<command>
++--knownhosts %LOGDIR/known%TESTNUMBER --key %LOGDIR/server/curl_client_key --pubkey %LOGDIR/server/curl_client_key.pub -u %USER: sftp://%HOSTIP:%SSHPORT%SFTP_PWD/%LOGDIR/file%TESTNUMBER.txt
++</command>
++<file name="%LOGDIR/file%TESTNUMBER.txt">
++Test data
++</file>
++</client>
++<verify>
++</verify>
++</testcase>
+diff --git a/tests/test3990.pl b/tests/test3990.pl
+new file mode 100644
+index 0000000..15f08c7
+--- /dev/null
++++ b/tests/test3990.pl
+@@ -0,0 +1,16 @@
++#!/usr/bin/env perl
++# Usage: test3990.pl host-public-key known-hosts-file first-name target-name
++# Writes a plain known_hosts file: an entry for first-name with a key of
++# another type, then the real host key for target-name.
++use strict;
++use warnings;
++my ($hostkey_file, $out, $first, $target) = @ARGV;
++open(my $fh, "<", $hostkey_file) or die "$!";
++my ($algo, $data) = split(/\s+/, <$fh>);
++close($fh);
++my $rsa = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCgSyqrUP2xhqLqkyopVapoKeucYIpZXeUqj+Q9WLWyXka5re62Y3R/lxZUXtkJjlpdD2LNMFenNlDQvPaXH5Utllt+c3zwOkOLy7RXX5S37SfQFm/0fPkZqoZfMDB6XDcwA4cakjCRn4oZyKs8dWAxoNaTtYcnKKMJ6rmc8PttykJw9fwiKAjPyYf21/BMvWIzu9req+TrDA/Jcd2UAug94CikJIXuwKmSYleAOo4eJWx8GyujgEgZn05eq+K1LSg9RqRVIxOdqjoE5K3abBfs0rmUuLdMFh7nHseTFXYbKzpz46V7iZMfFuoyURrzVsqGUm+/m7dxBM98In12kOm3";
++my $ed = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAqmXRY8k+W9GtpWxYru6ELAXYHdXqjf33ziITGTiJUN";
++my $other = ($algo eq "ssh-ed25519") ? $rsa : $ed;
++open(my $kh, ">", $out) or die "$!";
++print $kh "$first $other\n$target $algo $data\n";
++close($kh);
diff --git a/curl-CVE-2026-111483.patch b/curl-CVE-2026-111483.patch
new file mode 100644
index 0000000..b7a6e19
--- /dev/null
+++ b/curl-CVE-2026-111483.patch
@@ -0,0 +1,363 @@
+CVE-2026-111483: GnuTLS accepts non-successful OCSP staples
+https://github.com/curl/curl/commit/287df0b324268261654657549b77ee6f0dfee177
+
+diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c
+index 7955dba..650c5cf 100644
+--- a/lib/vtls/gtls.c
++++ b/lib/vtls/gtls.c
+@@ -1428,28 +1428,82 @@ static void gtls_infof_cert(struct Curl_easy *data,
+ }
+ 
+ static CURLcode gtls_verify_ocsp_status(struct Curl_easy *data,
+-                                        gnutls_session_t session)
++                                        gnutls_session_t session,
++                                        gnutls_x509_crt_t cert)
+ {
+-  gnutls_datum_t status_request;
+-  int rc;
+-
+-  /* We use gnutls_certificate_verify_peers2() to verify the result
+-   * which - according to GnuTLS documentation - already takes
+-   * an OCSP stapling extension received into account.
+-   * We therefore need only to check if we indeed received
+-   * a stapled OCSP response here. */
+-  rc = gnutls_ocsp_status_request_get(session, &status_request);
+-
++  gnutls_datum_t ocsp_raw;
++  gnutls_ocsp_resp_t ocsp_resp = NULL;
++  CURLcode result = CURLE_SSL_INVALIDCERTSTATUS;
++  int rc, idx;
++  bool ocsp_init = FALSE;
++  gnutls_ocsp_cert_status_t status = GNUTLS_OCSP_CERT_UNKNOWN;
++
++  /* Get the OCSP stapled response. We require it to be there. */
++  rc = gnutls_ocsp_status_request_get(session, &ocsp_raw);
+   if(rc == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
+     failf(data, "No OCSP response received");
+-    return CURLE_SSL_INVALIDCERTSTATUS;
++    goto out;
+   }
+   else if(rc < 0) {
+     failf(data, "Invalid OCSP response received");
+-    return CURLE_SSL_INVALIDCERTSTATUS;
++    goto out;
++  }
++  /* Parse the OCSP response, which needs to succeed. */
++  rc = gnutls_ocsp_resp_init(&ocsp_resp);
++  if(rc < 0) {
++    failf(data, "failed to init OCSP response parsing");
++    goto out;
++  }
++  ocsp_init = TRUE;
++  rc = gnutls_ocsp_resp_import(ocsp_resp, &ocsp_raw);
++  if(rc < 0) {
++    failf(data, "failed to parse OCSP response");
++    goto out;
++  }
++  /* OCSP responses carry a basic, overall status and then individual
++   * parts for different certificates. The overall status must be good. */
++  if(gnutls_ocsp_resp_get_status(ocsp_resp) != GNUTLS_OCSP_RESP_SUCCESSFUL) {
++    failf(data, "OCSP response basic part is not successful");
++    goto out;
++  }
++  /* Find the OCSP sub-response for the peer certificate. */
++  for(idx = 0;; idx++) {
++    rc = gnutls_ocsp_resp_check_crt(ocsp_resp, idx, cert);
++    if(!rc || (rc == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE))
++      break;
++  }
++  if(rc < 0) {
++    failf(data, "OCSP does not carry status for peer cert");
++    goto out;
++  }
++  /* The peer certificate OCSP status is at index `idx`.
++   * Coming here means that GnuTLS has already checked that
++   * - the signature of this OCSP status has been verified
++   * - the timestamp of this OCSP status has been tested
++   * We therefore need only to inspect that actual status code. */
++  rc = gnutls_ocsp_resp_get_single(ocsp_resp, idx, NULL, NULL, NULL, NULL,
++                                   &status, NULL, NULL, NULL, NULL);
++  if(rc < 0) {
++    failf(data, "failed to parse OCSP response for peer cert");
++    goto out;
++  }
++  switch(status) {
++  case GNUTLS_OCSP_CERT_GOOD:
++    /* We only regard this as OK and fail all other status codes. */
++    result = CURLE_OK;
++    break;
++  case GNUTLS_OCSP_CERT_REVOKED:
++    failf(data, "peer certificate is revoked");
++    break;
++  default:
++    failf(data, "peer certificate OCSP status is not good: %d", (int)status);
++    break;
+   }
+ 
+-  return CURLE_OK;
++out:
++  if(ocsp_init)
++    gnutls_ocsp_resp_deinit(ocsp_resp);
++  return result;
+ }
+ 
+ struct gtls_cert_chain {
+@@ -1693,7 +1747,7 @@ CURLcode Curl_gtls_verifyserver(struct Curl_cfilter *cf,
+   }
+ 
+   if(config->verifystatus) {
+-    result = gtls_verify_ocsp_status(data, session);
++    result = gtls_verify_ocsp_status(data, session, x509_cert);
+     if(result)
+       goto out;
+   }
+diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
+index 7bb7a8c..53aaebb 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -2270,7 +2270,12 @@ static CURLcode verifystatus(struct Curl_cfilter *cf,
+     goto end;
+   }
+ 
++#if !defined(HAVE_BORINGSSL_LIKE) && \
++  !(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3060000fL)
++  ch = SSL_get0_verified_chain(octx->ssl);
++#else
+   ch = SSL_get_peer_cert_chain(octx->ssl);
++#endif
+   if(!ch) {
+     failf(data, "Could not get peer certificate chain");
+     result = CURLE_SSL_INVALIDCERTSTATUS;
+diff --git a/tests/http/Makefile.am b/tests/http/Makefile.am
+index 40f5640..0d6c369 100644
+--- a/tests/http/Makefile.am
++++ b/tests/http/Makefile.am
+@@ -69,6 +69,7 @@ EXTRA_DIST =             \
+   test_21_resolve.py     \
+   test_22_httpsrr.py     \
+   test_23_ech.py         \
++  test_24_ocsp.py        \
+   test_30_vsftpd.py      \
+   test_31_vsftpds.py     \
+   test_32_ftps_vsftpd.py \
+diff --git a/tests/http/test_24_ocsp.py b/tests/http/test_24_ocsp.py
+new file mode 100644
+index 0000000..e37bd20
+--- /dev/null
++++ b/tests/http/test_24_ocsp.py
+@@ -0,0 +1,200 @@
++#***************************************************************************
++#                                  _   _ ____  _
++#  Project                     ___| | | |  _ \| |
++#                             / __| | | | |_) | |
++#                            | (__| |_| |  _ <| |___
++#                             \___|\___/|_| \_\_____|
++#
++# Copyright (C) Daniel Stenberg, <daniel at haxx.se>, et al.
++#
++# This software is licensed as described in the file COPYING, which
++# you should have received as part of this distribution. The terms
++# are also available at https://curl.se/docs/copyright.html.
++#
++# You may opt to use, copy, modify, merge, publish, distribute and/or sell
++# copies of the Software, and permit persons to whom the Software is
++# furnished to do so, under the terms of the COPYING file.
++#
++# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
++# KIND, either express or implied.
++#
++# SPDX-License-Identifier: curl
++#
++###########################################################################
++#
++import logging
++import os
++import shutil
++import socket
++import subprocess
++from typing import Dict
++
++import pytest
++from testenv import CurlClient, Env
++from testenv.ports import alloc_ports_and_do
++
++log = logging.getLogger(__name__)
++
++
++class OsslServer:
++
++    def __init__(self, env, domain, ocsp_case):
++        self.name = 'osslserver'
++        self.env = env
++        self.run_dir = os.path.join(env.gen_dir, self.name)
++        self.err_file = os.path.join(self.run_dir, 'stderr')
++        self._rmrf(self.run_dir)
++        self._mkpath(self.run_dir)
++        self.domain = domain
++        self.ocsp_case = ocsp_case
++        self.sproc = None
++        self.cerr = None
++        self.port = 0
++
++    def _mkpath(self, path):
++        if not os.path.exists(path):
++            os.makedirs(path)
++
++    def _rmrf(self, path):
++        if os.path.exists(path):
++            shutil.rmtree(path)
++
++    def _mk_ocsp_stat(self, ocsp_file, creds, index_content):
++        # make an OCSP status file for certificate 'creds' with
++        # content 'index_content'
++        ocsp_index = os.path.join(self.env.gen_dir, 'ocsp-index.der')
++        with open(ocsp_index, 'w') as fd:
++            fd.write(index_content)
++        ocsp_req = os.path.join(self.env.gen_dir, 'ocsp-req.der')
++        s = subprocess.run([
++            self.env.CONFIG.openssl, 'ocsp',
++            '-issuer', self.env.ca.cert_file,
++            '-cert', creds.cert_file,
++            '-no_nonce',
++            '-reqout', ocsp_req
++        ], stderr=self.cerr, stdout=self.cerr, check=True)
++        assert s.returncode == 0
++        s = subprocess.run([
++            self.env.CONFIG.openssl, 'ocsp',
++            '-index', ocsp_index,
++            '-rsigner', self.env.ca.cert_file,
++            '-rkey', self.env.ca.pkey_file,
++            '-CA', self.env.ca.cert_file,
++            '-reqin', ocsp_req,
++            '-respout', ocsp_file,
++            '-ndays', '1'
++        ], stderr=self.cerr, stdout=self.cerr, check=True)
++        assert s.returncode == 0
++
++    def startup(self):
++        self.cerr = open(self.err_file, 'w')  # noqa: SIM115
++        creds = self.env.get_credentials(self.domain)
++        assert creds  # convince pytype this is not None
++        ocsp_file = os.path.join(self.env.gen_dir, 'ocsp-stat.der')
++        if self.ocsp_case == 'trylater':
++            with open(ocsp_file, 'wb') as fd:
++                fd.write(b'\x30\x03\x0a\x01\x03')
++        elif self.ocsp_case == 'unauth':
++            with open(ocsp_file, 'wb') as fd:
++                fd.write(b'\x30\x03\x0a\x01\x06')
++        elif self.ocsp_case == 'interror':
++            with open(ocsp_file, 'wb') as fd:
++                fd.write(b'\x30\x03\x0a\x01\x02')
++        elif self.ocsp_case == 'unknown':
++            self._mk_ocsp_stat(ocsp_file, creds, '')
++        elif self.ocsp_case == 'revoked':
++            index_file = os.path.join(self.env.gen_dir, 'ocsp-index.txt')
++            # openssl wants hex numbers as complete bytes
++            serial = hex(creds.serial_number)[2:].upper()
++            serial = f'0{serial}' if len(serial) % 2 else serial
++            index = 'R\t301231000000Z\t240101000000Z,keyCompromise' \
++                f'\t{serial}\tunknown\t/{creds.subject.rfc4514_string()}\n'
++            with open(index_file, 'wb') as fd:
++                fd.write(index.encode())
++            self._mk_ocsp_stat(ocsp_file, creds, index)
++        elif self.ocsp_case == 'valid':
++            index_file = os.path.join(self.env.gen_dir, 'ocsp-index.txt')
++            # openssl wants hex numbers as complete bytes
++            serial = hex(creds.serial_number)[2:].upper()
++            serial = f'0{serial}' if len(serial) % 2 else serial
++            index = 'V\t301231000000Z\t240101000000Z,valid' \
++                f'\t{serial}\tunknown\t/{creds.subject.rfc4514_string()}\n'
++            with open(index_file, 'wb') as fd:
++                fd.write(index.encode())
++            self._mk_ocsp_stat(ocsp_file, creds, index)
++        elif self.ocsp_case:
++            assert False, f'unknown ocsp case: {self.ocsp_case}'
++
++        def startup(ports: Dict[str, int]) -> bool:
++            self.port = ports[self.name]
++            sargs = [
++                self.env.CONFIG.openssl, 's_server', '-www',
++                '-accept', f'{self.port}', '-tls1_2',
++                '-cert',  creds.cert_file, '-key', creds.pkey_file,
++            ]
++            if self.ocsp_case is not None:
++                sargs.extend(['-status_file', ocsp_file])
++            log.info(f'start_ {sargs}')
++            self.sproc = subprocess.Popen(args=sargs,
++                                          cwd=self.run_dir,
++                                          stderr=self.cerr,
++                                          stdout=self.cerr)
++            self.env.update_ports(ports)
++            return True
++
++        port_spec = {
++            self.name: socket.SOCK_STREAM
++        }
++        assert alloc_ports_and_do(port_spec, startup,
++                                  self.env.gen_root, max_tries=3)
++        assert self.sproc
++
++    def shutdown(self):
++        self.sproc.terminate()
++        self.cerr.close()
++
++    def set_ocsp_case(self, ocsp_case):
++        if self.ocsp_case != ocsp_case:
++            self.shutdown()
++            self.ocsp_case = ocsp_case
++            self.startup()
++
++
++ at pytest.mark.skipif(condition=not Env.have_openssl_ech(), reason="no modern openssl available")
++ at pytest.mark.skipif(condition=not Env.curl_can_cert_status(), reason="no cert-status in curl")
++class TestOCSP:
++
++    @pytest.fixture(autouse=True, scope='class')
++    @classmethod
++    def osslserver(cls, env):
++        server = OsslServer(env, env.domain1, None)
++        server.startup()
++        yield server
++        server.shutdown()
++
++    @pytest.mark.parametrize("cert_status, exp_ok, ocsp_case", [
++        [False, True, None],
++        [True, False, None],  # CURLE_SSL_INVALIDCERTSTATUS
++        [True, False, 'trylater'],
++        [True, False, 'unauth'],
++        [True, False, 'interror'],
++        [True, False, 'unknown'],
++        [True, False, 'revoked'],
++        [True,  True, 'valid'],
++    ])
++    def test_24_01_verify_status(self, env: Env, osslserver, cert_status, exp_ok, ocsp_case):
++        osslserver.set_ocsp_case(ocsp_case)
++        run_env = os.environ.copy()
++        xargs = []
++        if cert_status:
++            xargs.append('--cert-status')
++        curl = CurlClient(env=env, run_env=run_env)
++        url = f'https://{env.domain1}:{osslserver.port}/data.json'
++        r = curl.http_download(urls=[url], with_stats=True, extra_args=xargs)
++        if exp_ok:
++            r.check_exit_code(0)
++        elif ocsp_case == 'revoked':
++            # gnutls fails this with 60 as its internal checks fail early
++            assert r.exit_code in [60, 91], f'{r}'
++        else:
++            r.check_exit_code(91)
+diff --git a/tests/http/testenv/certs.py b/tests/http/testenv/certs.py
+index 3cf057b..2692635 100644
+--- a/tests/http/testenv/certs.py
++++ b/tests/http/testenv/certs.py
+@@ -146,6 +146,10 @@ class Credentials:
+     def subject(self) -> x509.Name:
+         return self._cert.subject
+ 
++    @property
++    def serial_number(self):
++        return self._cert.serial_number
++
+     @property
+     def key_type(self):
+         if isinstance(self._pkey, RSAPrivateKey):
diff --git a/curl-CVE-2026-111878.patch b/curl-CVE-2026-111878.patch
new file mode 100644
index 0000000..382c1e6
--- /dev/null
+++ b/curl-CVE-2026-111878.patch
@@ -0,0 +1,895 @@
+CVE-2026-111878: OpenSSL provider UAF on TLS shutdown
+https://github.com/curl/curl/commit/ec0a5d1b060f63336efb93134635cf46ebda920a
+
+diff --git a/docs/libcurl/opts/CURLOPT_SSLENGINE.md b/docs/libcurl/opts/CURLOPT_SSLENGINE.md
+index 85aa775..a0c2fc1 100644
+--- a/docs/libcurl/opts/CURLOPT_SSLENGINE.md
++++ b/docs/libcurl/opts/CURLOPT_SSLENGINE.md
+@@ -43,6 +43,10 @@ specified separated from the name with a colon (`:`).
+ Using this option multiple times makes the last set string override the
+ previous ones. Set it to NULL to disable its use again.
+ 
++Since curl 8.24.0, the engine and provider initialization is done during
++transfer setup, making many errors only detected then, not when set using
++curl_easy_setopt(3).
++
+ # DEFAULT
+ 
+ NULL
+@@ -71,11 +75,6 @@ int main(void)
+ 
+ CURLE_OK - Engine found.
+ 
+-CURLE_SSL_ENGINE_NOTFOUND - Engine not found, or OpenSSL was not built with
+-engine support.
+-
+-CURLE_SSL_ENGINE_INITFAILED - Engine found but initialization failed.
+-
+ CURLE_NOT_BUILT_IN - Option not built in, OpenSSL is not the SSL backend.
+ 
+ CURLE_UNKNOWN_OPTION - Option not recognized.
+diff --git a/lib/easy.c b/lib/easy.c
+index 9d467f4..58d3098 100644
+--- a/lib/easy.c
++++ b/lib/easy.c
+@@ -1006,7 +1006,6 @@ CURL *curl_easy_duphandle(CURL *curl)
+ 
+   if(CURL_EAPI_ENTER(&guard, curl, easy_duphandle, NULL)) {
+     struct Curl_easy *data = curl;
+-    const char *str;
+ 
+     outcurl = curlx_calloc(1, sizeof(struct Curl_easy));
+     if(!outcurl)
+@@ -1078,16 +1077,9 @@ CURL *curl_easy_duphandle(CURL *curl)
+         goto fail;
+     }
+ 
+-    /* Reinitialize an SSL engine for the new handle
+-     * note: the engine name has already been copied by dupset */
+-    str = CURL_EASY_STR(outcurl, STRING_SSL_ENGINE);
+-    if(str) {
+-      if(Curl_ssl_set_engine(outcurl, str))
+-        goto fail;
+-    }
+-
+ #ifndef CURL_DISABLE_ALTSVC
+     if(data->asi) {
++      const char *str;
+       outcurl->asi = Curl_altsvc_init();
+       if(!outcurl->asi)
+         goto fail;
+@@ -1098,6 +1090,7 @@ CURL *curl_easy_duphandle(CURL *curl)
+ #endif
+ #ifndef CURL_DISABLE_HSTS
+     if(data->hsts) {
++      const char *str;
+       outcurl->hsts = Curl_hsts_init();
+       if(!outcurl->hsts)
+         goto fail;
+diff --git a/lib/setopt.c b/lib/setopt.c
+index dff8a6d..a009803 100644
+--- a/lib/setopt.c
++++ b/lib/setopt.c
+@@ -930,8 +930,13 @@ static CURLcode setopt_long_ssl(struct Curl_easy *data, CURLoption option,
+   case CURLOPT_SSL_ENABLE_NPN:
+     break;
+   case CURLOPT_SSLENGINE_DEFAULT:
+-    CURL_EASY_STR_CLEAR(data, STRING_SSL_ENGINE);
+-    result = Curl_ssl_set_engine_default(data);
++#ifdef USE_OPENSSL
++    if(Curl_ssl_backend() != CURLSSLBACKEND_OPENSSL)
++      return CURLE_NOT_BUILT_IN;
++    data->set.engine_default = (arg == 1);
++#else
++    return CURLE_NOT_BUILT_IN;
++#endif
+     break;
+   default:
+     return CURLE_UNKNOWN_OPTION;
+@@ -1957,12 +1962,9 @@ static CURLcode setopt_cptr_ssl(struct Curl_easy *data, CURLoption option,
+     /*
+      * String that holds the SSL crypto engine.
+      */
+-    if(ptr && ptr[0]) {
+-      result = Curl_setstropt(data, STRING_SSL_ENGINE, ptr);
+-      if(!result) {
+-        result = Curl_ssl_set_engine(data, ptr);
+-      }
+-    }
++    if(Curl_ssl_backend() != CURLSSLBACKEND_OPENSSL)
++      return CURLE_NOT_BUILT_IN;
++    result = Curl_setstropt(data, STRING_SSL_ENGINE, ptr);
+     break;
+   case CURLOPT_ISSUERCERT:
+     /*
+diff --git a/lib/urldata.h b/lib/urldata.h
+index 249331d..db07bcc 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -556,15 +556,6 @@ struct UrlState {
+   struct Curl_resolv_async *async;  /* asynchronous name resolver data */
+ #endif
+ 
+-#ifdef USE_OPENSSL
+-  /* void instead of ENGINE to avoid bleeding OpenSSL into this header */
+-  void *engine;
+-  /* void instead of OSSL_PROVIDER */
+-  void *provider;
+-  void *baseprov;
+-  void *libctx;
+-  char *propq; /* for a provider */
+-#endif /* USE_OPENSSL */
+   struct expire_timers timeouts; /* expire timeouts */
+ 
+   /* a place to store the most recently set (S)FTP entrypath */
+@@ -638,9 +629,6 @@ struct UrlState {
+   uint8_t httpreq; /* Curl_HttpReq; what kind of HTTP request (if any)
+                             is this */
+ 
+-#ifdef USE_OPENSSL
+-  BIT(provider_loaded);
+-#endif /* USE_OPENSSL */
+   BIT(really_alive); /* transfer is really alive in multi, passed INIT */
+   BIT(this_is_a_follow); /* this is a followed Location: request */
+   BIT(refused_stream); /* this was refused, try again */
+@@ -1136,6 +1124,9 @@ struct UserDefined {
+   BIT(post301); /* keep POSTs as POSTs after a 301 request */
+   BIT(post302); /* keep POSTs as POSTs after a 302 request */
+   BIT(post303); /* keep POSTs as POSTs after a 303 request */
++#ifdef USE_OPENSSL
++  BIT(engine_default);
++#endif
+ };
+ 
+ #ifndef CURL_DISABLE_MIME
+diff --git a/lib/vquic/vquic-tls.c b/lib/vquic/vquic-tls.c
+index 99c0553..dbf8396 100644
+--- a/lib/vquic/vquic-tls.c
++++ b/lib/vquic/vquic-tls.c
+@@ -102,10 +102,7 @@ CURLcode Curl_vquic_tls_init(struct curl_tls_ctx *ctx,
+ void Curl_vquic_tls_cleanup(struct curl_tls_ctx *ctx)
+ {
+ #ifdef USE_OPENSSL
+-  if(ctx->ossl.ssl)
+-    SSL_free(ctx->ossl.ssl);
+-  if(ctx->ossl.ssl_ctx)
+-    SSL_CTX_free(ctx->ossl.ssl_ctx);
++  Curl_osslctx_cleanup(&ctx->ossl);
+ #elif defined(USE_GNUTLS)
+   if(ctx->gtls.session)
+     gnutls_deinit(ctx->gtls.session);
+diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c
+index 650c5cf..9d91393 100644
+--- a/lib/vtls/gtls.c
++++ b/lib/vtls/gtls.c
+@@ -2295,8 +2295,6 @@ const struct Curl_ssl Curl_ssl_gnutls = {
+   gtls_get_internals,            /* get_internals */
+   gtls_close,                    /* close_one */
+   NULL,                          /* close_all */
+-  NULL,                          /* set_engine */
+-  NULL,                          /* set_engine_default */
+   NULL,                          /* engines_list */
+   gtls_sha256sum,                /* sha256sum */
+   gtls_recv,                     /* recv decrypted data */
+diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c
+index c7cfc00..428c3f3 100644
+--- a/lib/vtls/mbedtls.c
++++ b/lib/vtls/mbedtls.c
+@@ -1711,8 +1711,6 @@ const struct Curl_ssl Curl_ssl_mbedtls = {
+   mbedtls_get_internals,            /* get_internals */
+   mbedtls_close,                    /* close_one */
+   NULL,                             /* close_all */
+-  NULL,                             /* set_engine */
+-  NULL,                             /* set_engine_default */
+   NULL,                             /* engines_list */
+   mbedtls_sha256sum,                /* sha256sum */
+   mbed_recv,                        /* recv decrypted data */
+diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
+index 53aaebb..947dcfb 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -903,9 +903,12 @@ static bool is_pkcs11_uri(const char *string)
+ 
+ #endif
+ 
+-static CURLcode ossl_set_engine(struct Curl_easy *data, const char *name);
++static CURLcode ossl_set_engine(struct Curl_easy *data, struct ossl_ctx *octx,
++                                const char *name);
+ #ifdef OPENSSL_HAS_PROVIDERS
+-static CURLcode ossl_set_provider(struct Curl_easy *data, const char *iname);
++static CURLcode ossl_set_provider(struct Curl_easy *data,
++                                  struct ossl_ctx *octx,
++                                  const char *iname);
+ #endif
+ 
+ static int use_certificate_blob(SSL_CTX *ctx, const struct curl_blob *blob,
+@@ -1027,20 +1030,21 @@ end:
+ }
+ 
+ static int enginecheck(struct Curl_easy *data,
+-                       SSL_CTX* ctx,
++                       struct ossl_ctx *octx,
+                        const char *key_file,
+                        const char *key_passwd)
+ {
+ #ifdef USE_OPENSSL_ENGINE
+   EVP_PKEY *priv_key = NULL;
++  SSL_CTX *ctx = octx->ssl_ctx;
+ 
+   /* Implicitly use pkcs11 engine if none was provided and the
+    * key_file is a PKCS#11 URI */
+-  if(!data->state.engine && is_pkcs11_uri(key_file) &&
+-     ossl_set_engine(data, "pkcs11") != CURLE_OK)
++  if(!octx->p.engine && is_pkcs11_uri(key_file) &&
++     ossl_set_engine(data, octx, "pkcs11") != CURLE_OK)
+     return 0;
+ 
+-  if(data->state.engine) {
++  if(octx->p.engine) {
+     UI_METHOD *ui_method = UI_create_method("curl user interface");
+     if(!ui_method) {
+       failf(data, "unable to create " OSSL_PACKAGE " user-interface method");
+@@ -1050,7 +1054,7 @@ static int enginecheck(struct Curl_easy *data,
+     UI_method_set_closer(ui_method, UI_method_get_closer(UI_OpenSSL()));
+     UI_method_set_reader(ui_method, ssl_ui_reader);
+     UI_method_set_writer(ui_method, ssl_ui_writer);
+-    priv_key = ENGINE_load_private_key(data->state.engine, key_file,
++    priv_key = ENGINE_load_private_key(octx->p.engine, key_file,
+                                        ui_method,
+                                        CURL_UNCONST(key_passwd));
+     UI_destroy_method(ui_method);
+@@ -1071,7 +1075,7 @@ static int enginecheck(struct Curl_easy *data,
+   }
+   return 1;
+ #else
+-  (void)ctx;
++  (void)octx;
+   (void)key_file;
+   (void)key_passwd;
+   failf(data, "SSL_FILETYPE_ENGINE not supported for private key");
+@@ -1080,19 +1084,21 @@ static int enginecheck(struct Curl_easy *data,
+ }
+ 
+ static int providercheck(struct Curl_easy *data,
+-                         SSL_CTX* ctx,
++                         struct ossl_ctx *octx,
+                          const char *key_file)
+ {
+ #ifdef OPENSSL_HAS_PROVIDERS
+   char error_buffer[256];
++  SSL_CTX *ctx = octx->ssl_ctx;
++
+   /* Implicitly use pkcs11 provider if none was provided and the
+    * key_file is a PKCS#11 URI */
+-  if(!data->state.provider_loaded && is_pkcs11_uri(key_file) &&
+-     ossl_set_provider(data, "pkcs11") != CURLE_OK) {
++  if(!octx->p.provider_loaded && is_pkcs11_uri(key_file) &&
++     ossl_set_provider(data, octx, "pkcs11") != CURLE_OK) {
+     return 0;
+   }
+ 
+-  if(data->state.provider_loaded) {
++  if(octx->p.provider_loaded) {
+     /* Load the private key from the provider */
+     EVP_PKEY *priv_key = NULL;
+     OSSL_STORE_CTX *store = NULL;
+@@ -1107,8 +1113,8 @@ static int providercheck(struct Curl_easy *data,
+     UI_method_set_reader(ui_method, ssl_ui_reader);
+     UI_method_set_writer(ui_method, ssl_ui_writer);
+ 
+-    store = OSSL_STORE_open_ex(key_file, data->state.libctx,
+-                               data->state.propq, ui_method, NULL, NULL,
++    store = OSSL_STORE_open_ex(key_file, octx->p.libctx,
++                               octx->p.propq, ui_method, NULL, NULL,
+                                NULL, NULL);
+     if(!store) {
+       failf(data, "Failed to open OpenSSL store: %s",
+@@ -1155,7 +1161,7 @@ static int providercheck(struct Curl_easy *data,
+   }
+   return 1;
+ #else
+-  (void)ctx;
++  (void)octx;
+   (void)key_file;
+   failf(data, "SSL_FILETYPE_PROVIDER not supported for private key");
+   return 0;
+@@ -1163,19 +1169,21 @@ static int providercheck(struct Curl_easy *data,
+ }
+ 
+ static int engineload(struct Curl_easy *data,
+-                      SSL_CTX* ctx,
++                      struct ossl_ctx *octx,
+                       const char *cert_file)
+ {
+ /* ENGINE_CTRL_GET_CMD_FROM_NAME supported by OpenSSL, LibreSSL <=3.8.3 */
+ #if defined(USE_OPENSSL_ENGINE) && defined(ENGINE_CTRL_GET_CMD_FROM_NAME)
+   char error_buffer[256];
+-  /* Implicitly use pkcs11 engine if none was provided and the
+-   * cert_file is a PKCS#11 URI */
+-  if(!data->state.engine && is_pkcs11_uri(cert_file) &&
+-     ossl_set_engine(data, "pkcs11") != CURLE_OK)
++  SSL_CTX *ctx = octx->ssl_ctx;
++
++  /* Implicitly use pkcs11 engine if none was provided and the cert_file is a
++   * PKCS#11 URI */
++  if(!octx->p.engine && is_pkcs11_uri(cert_file) &&
++     ossl_set_engine(data, octx, "pkcs11") != CURLE_OK)
+     return 0;
+ 
+-  if(data->state.engine) {
++  if(octx->p.engine) {
+     static const char cmd_name[] = "LOAD_CERT_CTRL";
+     struct {
+       const char *cert_id;
+@@ -1186,14 +1194,14 @@ static int engineload(struct Curl_easy *data,
+     params.cert = NULL;
+ 
+     /* Does the engine supports LOAD_CERT_CTRL ? */
+-    if(!ENGINE_ctrl(data->state.engine, ENGINE_CTRL_GET_CMD_FROM_NAME,
++    if(!ENGINE_ctrl(octx->p.engine, ENGINE_CTRL_GET_CMD_FROM_NAME,
+                     0, CURL_UNCONST(cmd_name), NULL)) {
+       failf(data, "SSL engine does not support loading certificates");
+       return 0;
+     }
+ 
+     /* Load the certificate from the engine */
+-    if(!ENGINE_ctrl_cmd(data->state.engine, cmd_name, 0, &params, NULL, 1)) {
++    if(!ENGINE_ctrl_cmd(octx->p.engine, cmd_name, 0, &params, NULL, 1)) {
+       failf(data, "SSL engine cannot load client cert with id '%s' [%s]",
+             cert_file,
+             ossl_strerror(ERR_get_error(), error_buffer,
+@@ -1221,7 +1229,7 @@ static int engineload(struct Curl_easy *data,
+   }
+   return 1;
+ #else
+-  (void)ctx;
++  (void)octx;
+   (void)cert_file;
+   failf(data, "SSL_FILETYPE_ENGINE not supported for certificate");
+   return 0;
+@@ -1229,23 +1237,25 @@ static int engineload(struct Curl_easy *data,
+ }
+ 
+ static int providerload(struct Curl_easy *data,
+-                        SSL_CTX* ctx,
++                        struct ossl_ctx *octx,
+                         const char *cert_file)
+ {
+ #ifdef OPENSSL_HAS_PROVIDERS
+   char error_buffer[256];
+-  /* Implicitly use pkcs11 provider if none was provided and the
+-   * cert_file is a PKCS#11 URI */
+-  if(!data->state.provider_loaded && is_pkcs11_uri(cert_file) &&
+-     ossl_set_provider(data, "pkcs11") != CURLE_OK)
++  SSL_CTX *ctx = octx->ssl_ctx;
++
++  /* Implicitly use pkcs11 provider if none was provided and the cert_file is
++   * a PKCS#11 URI */
++  if(!octx->p.provider_loaded && is_pkcs11_uri(cert_file) &&
++     ossl_set_provider(data, octx, "pkcs11") != CURLE_OK)
+     return 0;
+ 
+-  if(data->state.provider_loaded) {
++  if(octx->p.provider_loaded) {
+     /* Load the certificate from the provider */
+     OSSL_STORE_INFO *info = NULL;
+     X509 *cert = NULL;
+     OSSL_STORE_CTX *store =
+-      OSSL_STORE_open_ex(cert_file, data->state.libctx,
++      OSSL_STORE_open_ex(cert_file, octx->p.libctx,
+                          NULL, NULL, NULL, NULL, NULL, NULL);
+     int rc;
+ 
+@@ -1293,7 +1303,7 @@ static int providerload(struct Curl_easy *data,
+   }
+   return 1;
+ #else
+-  (void)ctx;
++  (void)octx;
+   (void)cert_file;
+   failf(data, "SSL_FILETYPE_PROVIDER not supported for certificate");
+   return 0;
+@@ -1416,7 +1426,7 @@ fail:
+ }
+ 
+ static CURLcode client_cert(struct Curl_easy *data,
+-                            SSL_CTX* ctx,
++                            struct ossl_ctx *octx,
+                             char *cert_file,
+                             const struct curl_blob *cert_blob,
+                             const char *cert_type,
+@@ -1428,6 +1438,7 @@ static CURLcode client_cert(struct Curl_easy *data,
+   char error_buffer[256];
+   bool check_privkey = TRUE;
+   int file_type = ossl_do_file_type(cert_type);
++  SSL_CTX *ctx = octx->ssl_ctx;
+ 
+   if(cert_file || cert_blob || (file_type == SSL_FILETYPE_ENGINE) ||
+      (file_type == SSL_FILETYPE_PROVIDER)) {
+@@ -1482,12 +1493,12 @@ static CURLcode client_cert(struct Curl_easy *data,
+       break;
+ 
+     case SSL_FILETYPE_ENGINE:
+-      if(!cert_file || !engineload(data, ctx, cert_file))
++      if(!cert_file || !engineload(data, octx, cert_file))
+         return CURLE_SSL_CERTPROBLEM;
+       break;
+ 
+     case SSL_FILETYPE_PROVIDER:
+-      if(!cert_file || !providerload(data, ctx, cert_file))
++      if(!cert_file || !providerload(data, octx, cert_file))
+         return CURLE_SSL_CERTPROBLEM;
+       break;
+ 
+@@ -1523,12 +1534,12 @@ static CURLcode client_cert(struct Curl_easy *data,
+       }
+       break;
+     case SSL_FILETYPE_ENGINE:
+-      if(!enginecheck(data, ctx, key_file, key_passwd))
++      if(!enginecheck(data, octx, key_file, key_passwd))
+         return CURLE_SSL_CERTPROBLEM;
+       break;
+ 
+     case SSL_FILETYPE_PROVIDER:
+-      if(!providercheck(data, ctx, key_file))
++      if(!providercheck(data, octx, key_file))
+         return CURLE_SSL_CERTPROBLEM;
+       break;
+ 
+@@ -1650,7 +1661,8 @@ static void ossl_cleanup(void)
+ 
+ /* Selects an OpenSSL crypto engine or provider.
+  */
+-static CURLcode ossl_set_engine(struct Curl_easy *data, const char *name)
++static CURLcode ossl_set_engine(struct Curl_easy *data, struct ossl_ctx *octx,
++                                const char *name)
+ {
+ #ifdef USE_OPENSSL_ENGINE
+   CURLcode result = CURLE_SSL_ENGINE_NOTFOUND;
+@@ -1658,10 +1670,10 @@ static CURLcode ossl_set_engine(struct Curl_easy *data, const char *name)
+ 
+   if(e) {
+ 
+-    if(data->state.engine) {
+-      ENGINE_finish(data->state.engine);
+-      ENGINE_free(data->state.engine);
+-      data->state.engine = NULL;
++    if(octx->p.engine) {
++      ENGINE_finish(octx->p.engine);
++      ENGINE_free(octx->p.engine);
++      octx->p.engine = NULL;
+     }
+     if(!ENGINE_init(e)) {
+       char buf[256];
+@@ -1675,13 +1687,14 @@ static CURLcode ossl_set_engine(struct Curl_easy *data, const char *name)
+     else {
+       result = CURLE_OK;
+     }
+-    data->state.engine = e;
++    octx->p.engine = e;
+     return result;
+   }
+ #endif
+ #ifdef OPENSSL_HAS_PROVIDERS
+-  return ossl_set_provider(data, name);
++  return ossl_set_provider(data, octx, name);
+ #else
++  (void)octx;
+   (void)name;
+   failf(data, "OpenSSL engine not found");
+   return CURLE_SSL_ENGINE_NOTFOUND;
+@@ -1690,22 +1703,24 @@ static CURLcode ossl_set_engine(struct Curl_easy *data, const char *name)
+ 
+ /* Sets engine as default for all SSL operations
+  */
+-static CURLcode ossl_set_engine_default(struct Curl_easy *data)
++static CURLcode ossl_set_engine_default(struct Curl_easy *data,
++                                        struct ossl_ctx *octx)
+ {
+ #ifdef USE_OPENSSL_ENGINE
+-  if(data->state.engine) {
+-    if(ENGINE_set_default(data->state.engine, ENGINE_METHOD_ALL) > 0) {
++  if(octx->p.engine) {
++    if(ENGINE_set_default(octx->p.engine, ENGINE_METHOD_ALL) > 0) {
+       infof(data, "set default crypto engine '%s'",
+-            ENGINE_get_id(data->state.engine));
++            ENGINE_get_id(octx->p.engine));
+     }
+     else {
+       failf(data, "set default crypto engine '%s' failed",
+-            ENGINE_get_id(data->state.engine));
++            ENGINE_get_id(octx->p.engine));
+       return CURLE_SSL_ENGINE_SETFAILED;
+     }
+   }
+ #else
+   (void)data;
++  (void)octx;
+ #endif
+   return CURLE_OK;
+ }
+@@ -1734,20 +1749,22 @@ static struct curl_slist *ossl_engines_list(struct Curl_easy *data)
+ 
+ #ifdef OPENSSL_HAS_PROVIDERS
+ 
+-static void ossl_provider_cleanup(struct Curl_easy *data)
++static void ossl_provider_cleanup(struct ossl_ctx *octx)
+ {
+-  if(data->state.baseprov) {
+-    OSSL_PROVIDER_unload(data->state.baseprov);
+-    data->state.baseprov = NULL;
+-  }
+-  if(data->state.provider) {
+-    OSSL_PROVIDER_unload(data->state.provider);
+-    data->state.provider = NULL;
+-  }
+-  OSSL_LIB_CTX_free(data->state.libctx);
+-  data->state.libctx = NULL;
+-  curlx_safefree(data->state.propq);
+-  data->state.provider_loaded = FALSE;
++  if(!octx)
++    return;
++  if(octx->p.baseprov) {
++    OSSL_PROVIDER_unload(octx->p.baseprov);
++    octx->p.baseprov = NULL;
++  }
++  if(octx->p.provider) {
++    OSSL_PROVIDER_unload(octx->p.provider);
++    octx->p.provider = NULL;
++  }
++  OSSL_LIB_CTX_free(octx->p.libctx);
++  octx->p.libctx = NULL;
++  curlx_safefree(octx->p.propq);
++  octx->p.provider_loaded = FALSE;
+ }
+ 
+ #define MAX_PROVIDER_LEN 128 /* reasonable */
+@@ -1760,7 +1777,9 @@ static void ossl_provider_cleanup(struct Curl_easy *data)
+  *
+  * An example provider + property looks like "tpm2:?provider=tpm2".
+  */
+-static CURLcode ossl_set_provider(struct Curl_easy *data, const char *iname)
++static CURLcode ossl_set_provider(struct Curl_easy *data,
++                                  struct ossl_ctx *octx,
++                                  const char *iname)
+ {
+   char name[MAX_PROVIDER_LEN + 1];
+   struct Curl_str prov;
+@@ -1768,7 +1787,7 @@ static CURLcode ossl_set_provider(struct Curl_easy *data, const char *iname)
+ 
+   if(!iname) {
+     /* clear and cleanup provider use */
+-    ossl_provider_cleanup(data);
++    ossl_provider_cleanup(octx);
+     return CURLE_OK;
+   }
+   if(curlx_str_until(&iname, &prov, MAX_PROVIDER_LEN, ':'))
+@@ -1782,54 +1801,56 @@ static CURLcode ossl_set_provider(struct Curl_easy *data, const char *iname)
+   memcpy(name, curlx_str(&prov), curlx_strlen(&prov));
+   name[curlx_strlen(&prov)] = 0;
+ 
+-  if(!data->state.libctx) {
++  if(!octx->p.libctx) {
+     OSSL_LIB_CTX *libctx = OSSL_LIB_CTX_new();
+     if(!libctx)
+       return CURLE_OUT_OF_MEMORY;
+     if(propq) {
+-      data->state.propq = curlx_strdup(propq);
+-      if(!data->state.propq) {
++      octx->p.propq = curlx_strdup(propq);
++      if(!octx->p.propq) {
+         OSSL_LIB_CTX_free(libctx);
+         return CURLE_OUT_OF_MEMORY;
+       }
+     }
+-    data->state.libctx = libctx;
++    octx->p.libctx = libctx;
+   }
+ 
+ #ifndef CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG
+   /* load the configuration file into the library context before checking the
+    * provider availability */
+-  if(!OSSL_LIB_CTX_load_config(data->state.libctx, NULL)) {
++  if(!OSSL_LIB_CTX_load_config(octx->p.libctx, NULL)) {
+     infof(data, "Failed to load default openssl config. Proceeding.");
+   }
+ #endif
+ 
+-  if(OSSL_PROVIDER_available(data->state.libctx, name)) {
++  if(OSSL_PROVIDER_available(octx->p.libctx, name)) {
+     /* already loaded through the configuration - no action needed */
+-    data->state.provider_loaded = TRUE;
++    octx->p.provider_loaded = TRUE;
+     return CURLE_OK;
+   }
+ 
+-  data->state.provider = OSSL_PROVIDER_try_load(data->state.libctx, name, 1);
+-  if(!data->state.provider) {
++  octx->p.provider = OSSL_PROVIDER_try_load(octx->p.libctx, name, 1);
++  if(!octx->p.provider) {
+     char error_buffer[256];
+     failf(data, "Failed to initialize provider: %s",
+           ossl_strerror(ERR_get_error(), error_buffer, sizeof(error_buffer)));
+-    ossl_provider_cleanup(data);
++    ossl_provider_cleanup(octx);
+     return CURLE_SSL_ENGINE_NOTFOUND;
+   }
+ 
+   /* load the base provider as well */
+-  data->state.baseprov = OSSL_PROVIDER_try_load(data->state.libctx, "base", 1);
+-  if(!data->state.baseprov) {
+-    ossl_provider_cleanup(data);
++  octx->p.baseprov = OSSL_PROVIDER_try_load(octx->p.libctx, "base", 1);
++  if(!octx->p.baseprov) {
++    ossl_provider_cleanup(octx);
+     failf(data, "Failed to load base");
+     return CURLE_SSL_ENGINE_NOTFOUND;
+   }
+   else
+-    data->state.provider_loaded = TRUE;
++    octx->p.provider_loaded = TRUE;
+   return CURLE_OK;
+ }
++#else /* OPENSSL_HAS_PROVIDERS */
++#define ossl_provider_cleanup(x)
+ #endif
+ 
+ static CURLcode ossl_shutdown(struct Curl_cfilter *cf,
+@@ -1953,15 +1974,10 @@ out:
+   return result;
+ }
+ 
+-static void ossl_close(struct Curl_cfilter *cf, struct Curl_easy *data)
++/* also used by quic-tls */
++void Curl_osslctx_cleanup(struct ossl_ctx *octx)
+ {
+-  struct ssl_connect_data *connssl = cf->ctx;
+-  struct ossl_ctx *octx = (struct ossl_ctx *)connssl->backend;
+-
+-  (void)data;
+   DEBUGASSERT(octx);
+-
+-  connssl->input_pending = FALSE;
+   if(octx->ssl) {
+     SSL_free(octx->ssl);
+     octx->ssl = NULL;
+@@ -1975,6 +1991,22 @@ static void ossl_close(struct Curl_cfilter *cf, struct Curl_easy *data)
+     ossl_bio_cf_method_free(octx->bio_method);
+     octx->bio_method = NULL;
+   }
++#ifdef USE_OPENSSL_ENGINE
++  if(octx->p.engine) {
++    ENGINE_finish(octx->p.engine);
++    ENGINE_free(octx->p.engine);
++    octx->p.engine = NULL;
++  }
++#endif
++  ossl_provider_cleanup(octx);
++}
++
++static void ossl_close(struct Curl_cfilter *cf, struct Curl_easy *data)
++{
++  struct ssl_connect_data *connssl = cf->ctx;
++  struct ossl_ctx *octx = (struct ossl_ctx *)connssl->backend;
++  (void)data;
++  Curl_osslctx_cleanup(octx);
+ }
+ 
+ /*
+@@ -1983,18 +2015,7 @@ static void ossl_close(struct Curl_cfilter *cf, struct Curl_easy *data)
+  */
+ static void ossl_close_all(struct Curl_easy *data)
+ {
+-#ifdef USE_OPENSSL_ENGINE
+-  if(data->state.engine) {
+-    ENGINE_finish(data->state.engine);
+-    ENGINE_free(data->state.engine);
+-    data->state.engine = NULL;
+-  }
+-#else
+   (void)data;
+-#endif
+-#ifdef OPENSSL_HAS_PROVIDERS
+-  ossl_provider_cleanup(data);
+-#endif
+ }
+ 
+ /* ====================================================== */
+@@ -3731,17 +3752,23 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
+   char * const ssl_cert = conn_config->clientcert;
+   const struct curl_blob *ssl_cert_blob = conn_config->cert_blob;
+   const char * const ssl_cert_type = conn_config->cert_type;
+-  unsigned int ssl_version_min;
++  unsigned int ssl_version_min = CURL_SSLVERSION_DEFAULT;
+   char error_buffer[256];
+ 
+   /* Make funny stuff to get random input */
+   result = ossl_seed(data);
+-  if(result)
+-    return result;
+-
+-  ssl_config->certverifyresult = !X509_V_OK;
++  if(!result) {
++    if(CURL_EASY_STR(data, STRING_SSL_ENGINE))
++      result = ossl_set_engine(data, octx,
++                               CURL_EASY_STR(data, STRING_SSL_ENGINE));
++    if(!result && data->set.engine_default)
++      result = ossl_set_engine_default(data, octx);
++  }
+ 
+-  result = ossl_init_method(cf, data, peer, &req_method, &ssl_version_min);
++  if(!result) {
++    ssl_config->certverifyresult = !X509_V_OK;
++    result = ossl_init_method(cf, data, peer, &req_method, &ssl_version_min);
++  }
+   if(result)
+     return result;
+   DEBUGASSERT(req_method);
+@@ -3749,8 +3776,8 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
+   DEBUGASSERT(!octx->ssl_ctx);
+   octx->ssl_ctx =
+ #ifdef OPENSSL_HAS_PROVIDERS
+-    data->state.libctx ?
+-    SSL_CTX_new_ex(data->state.libctx, data->state.propq, req_method):
++    octx->p.libctx ?
++    SSL_CTX_new_ex(octx->p.libctx, octx->p.propq, req_method):
+ #endif
+     SSL_CTX_new(req_method);
+ 
+@@ -3759,11 +3786,6 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
+           ossl_strerror(ERR_peek_error(), error_buffer, sizeof(error_buffer)));
+     return CURLE_OUT_OF_MEMORY;
+   }
+-#ifdef OPENSSL_HAS_PROVIDERS
+-  if(data->state.libctx)
+-    /* forbid connection reuse with provider/engine use */
+-    connclose(data->conn);
+-#endif
+ 
+   if(cb_setup) {
+     result = cb_setup(cf, data, cb_user_data);
+@@ -3899,7 +3921,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
+ #endif
+ 
+   if(ssl_cert || ssl_cert_blob || ssl_cert_type) {
+-    result = client_cert(data, octx->ssl_ctx,
++    result = client_cert(data, octx,
+                          ssl_cert, ssl_cert_blob, ssl_cert_type,
+                          conn_config->key, conn_config->key_blob,
+                          conn_config->key_type,
+@@ -5580,8 +5602,6 @@ const struct Curl_ssl Curl_ssl_openssl = {
+   ossl_get_internals,       /* get_internals */
+   ossl_close,               /* close_one */
+   ossl_close_all,           /* close_all */
+-  ossl_set_engine,          /* set_engine or provider */
+-  ossl_set_engine_default,  /* set_engine_default */
+   ossl_engines_list,        /* engines_list */
+   ossl_sha256sum,           /* sha256sum */
+   ossl_recv,                /* recv decrypted data */
+diff --git a/lib/vtls/openssl.h b/lib/vtls/openssl.h
+index f1e914c..fed5575 100644
+--- a/lib/vtls/openssl.h
++++ b/lib/vtls/openssl.h
+@@ -112,12 +112,24 @@ struct alpn_spec;
+ struct ssl_peer;
+ struct Curl_ssl_session;
+ 
++struct provider {
++  /* void instead of ENGINE to avoid bleeding OpenSSL into this header */
++  void *engine;
++  /* void instead of OSSL_PROVIDER */
++  void *provider;
++  void *baseprov;
++  void *libctx;
++  char *propq; /* for a provider */
++  BIT(provider_loaded);
++};
++
+ /* Struct to hold a curl OpenSSL instance */
+ struct ossl_ctx {
+   /* these ones requires specific SSL-types */
+   SSL_CTX *ssl_ctx;
+   SSL *ssl;
+   BIO_METHOD *bio_method;
++  struct provider p;
+   CURLcode io_result;       /* result of last BIO cfilter operation */
+   /* blocked writes need to retry with same length, remember it */
+   int blocked_ssl_write_len;
+@@ -204,5 +216,7 @@ CURLcode Curl_ossl_check_peer_cert(struct Curl_cfilter *cf,
+ /* Report properties of a successful handshake */
+ void Curl_ossl_report_handshake(struct Curl_easy *data, struct ossl_ctx *octx);
+ 
++void Curl_osslctx_cleanup(struct ossl_ctx *octx);
++
+ #endif /* USE_OPENSSL */
+ #endif /* HEADER_CURL_SSLUSE_H */
+diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c
+index 72edac9..cfaa51c 100644
+--- a/lib/vtls/rustls.c
++++ b/lib/vtls/rustls.c
+@@ -1478,8 +1478,6 @@ const struct Curl_ssl Curl_ssl_rustls = {
+   cr_get_internals,                /* get_internals */
+   cr_close,                        /* close_one */
+   NULL,                            /* close_all */
+-  NULL,                            /* set_engine */
+-  NULL,                            /* set_engine_default */
+   NULL,                            /* engines_list */
+   NULL,                            /* sha256sum */
+   cr_recv,                         /* recv decrypted data */
+diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c
+index 2832bb3..837ceeb 100644
+--- a/lib/vtls/schannel.c
++++ b/lib/vtls/schannel.c
+@@ -2916,8 +2916,6 @@ const struct Curl_ssl Curl_ssl_schannel = {
+   schannel_get_internals,            /* get_internals */
+   schannel_close,                    /* close_one */
+   NULL,                              /* close_all */
+-  NULL,                              /* set_engine */
+-  NULL,                              /* set_engine_default */
+   NULL,                              /* engines_list */
+   schannel_sha256sum,                /* sha256sum */
+   schannel_recv,                     /* recv decrypted data */
+diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c
+index 9737319..ec03dd8 100644
+--- a/lib/vtls/vtls.c
++++ b/lib/vtls/vtls.c
+@@ -256,24 +256,6 @@ CURLcode Curl_ssl_adjust_pollset(struct Curl_cfilter *cf,
+   return CURLE_OK;
+ }
+ 
+-/* Selects an SSL crypto engine
+- */
+-CURLcode Curl_ssl_set_engine(struct Curl_easy *data, const char *engine)
+-{
+-  if(Curl_ssl->set_engine)
+-    return Curl_ssl->set_engine(data, engine);
+-  return CURLE_NOT_BUILT_IN;
+-}
+-
+-/* Selects the default SSL crypto engine
+- */
+-CURLcode Curl_ssl_set_engine_default(struct Curl_easy *data)
+-{
+-  if(Curl_ssl->set_engine_default)
+-    return Curl_ssl->set_engine_default(data);
+-  return CURLE_NOT_BUILT_IN;
+-}
+-
+ /* Return list of OpenSSL crypto engine names. */
+ struct curl_slist *Curl_ssl_engines_list(struct Curl_easy *data)
+ {
+@@ -675,8 +657,6 @@ static const struct Curl_ssl Curl_ssl_multi = {
+   multissl_get_internals,            /* get_internals */
+   multissl_close,                    /* close_one */
+   NULL,                              /* close_all */
+-  NULL,                              /* set_engine */
+-  NULL,                              /* set_engine_default */
+   NULL,                              /* engines_list */
+   NULL,                              /* sha256sum */
+   multissl_recv_plain,               /* recv decrypted data */
+diff --git a/lib/vtls/vtls_int.h b/lib/vtls/vtls_int.h
+index 7c1881b..7e6fbdf 100644
+--- a/lib/vtls/vtls_int.h
++++ b/lib/vtls/vtls_int.h
+@@ -174,8 +174,6 @@ struct Curl_ssl {
+   void (*close)(struct Curl_cfilter *cf, struct Curl_easy *data);
+   void (*close_all)(struct Curl_easy *data);
+ 
+-  CURLcode (*set_engine)(struct Curl_easy *data, const char *engine);
+-  CURLcode (*set_engine_default)(struct Curl_easy *data);
+   struct curl_slist *(*engines_list)(struct Curl_easy *data);
+ 
+   CURLcode (*sha256sum)(const unsigned char *input, size_t inputlen,
+diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c
+index f3bea53..70646b4 100644
+--- a/lib/vtls/wolfssl.c
++++ b/lib/vtls/wolfssl.c
+@@ -2312,8 +2312,6 @@ const struct Curl_ssl Curl_ssl_wolfssl = {
+   wssl_get_internals,              /* get_internals */
+   wssl_close,                      /* close_one */
+   NULL,                            /* close_all */
+-  NULL,                            /* set_engine */
+-  NULL,                            /* set_engine_default */
+   NULL,                            /* engines_list */
+   wssl_sha256sum,                  /* sha256sum */
+   wssl_recv,                       /* recv decrypted data */
diff --git a/curl-CVE-2026-111950.patch b/curl-CVE-2026-111950.patch
new file mode 100644
index 0000000..ca18982
--- /dev/null
+++ b/curl-CVE-2026-111950.patch
@@ -0,0 +1,54 @@
+CVE-2026-111950: TLS session cache diff scheme reuse
+https://github.com/curl/curl/commit/5d4eaac8f222643a1a59f3567e0e58498388d4fe
+adapted to 8.23.0, which lacks the KEY-V2 key format marker
+
+diff --git a/lib/vtls/vtls_scache.c b/lib/vtls/vtls_scache.c
+index 7192be2..52ae7bc 100644
+--- a/lib/vtls/vtls_scache.c
++++ b/lib/vtls/vtls_scache.c
+@@ -238,7 +238,8 @@ static CURLcode ssl_peer_key_build(struct ssl_filter_config *ssl,
+   *ppeer_key = NULL;
+   curlx_dyn_init(&buf, 10 * 1024);
+ 
+-  result = curlx_dyn_addf(&buf, "%s:%d",
++  result = curlx_dyn_addf(&buf, "%s:%s:%d",
++                          peer->origin->scheme->name,
+                           peer->origin->hostname, peer->origin->port);
+   if(result)
+     goto out;
+diff --git a/tests/unit/unit3304.c b/tests/unit/unit3304.c
+index 1d5546a..f0ba2de 100644
+--- a/tests/unit/unit3304.c
++++ b/tests/unit/unit3304.c
+@@ -46,6 +46,7 @@ static CURLcode test_unit3304(const char *arg)
+   struct Curl_peer origin;
+   struct ssl_peer peer;
+   struct ssl_filter_config ssl;
++  struct Curl_scheme scheme;
+   char *key1 = NULL;
+   char *key2 = NULL;
+   static char base_hostname[] = "example.com";
+@@ -60,9 +61,13 @@ static CURLcode test_unit3304(const char *arg)
+   static char lc_ctype[]      = "pem";
+   static char lc_ktype[]      = "pem";
+ 
++  memset(&scheme, 0, sizeof(scheme));
++  scheme.name = "https";
++
+   memset(&origin, 0, sizeof(origin));
+   origin.hostname = base_hostname;
+   origin.port = 443;
++  origin.scheme = &scheme;
+ 
+   memset(&peer, 0, sizeof(peer));
+   peer.origin = &origin;
+@@ -84,6 +89,9 @@ static CURLcode test_unit3304(const char *arg)
+               "peer key build failed");
+   fail_unless(key1 && key2 && !strcmp(key1, key2),
+               "identical config should produce identical peer key");
++  fail_unless(key1 && !strncmp(key1, "https:example.com:443:",
++                               sizeof("https:example.com:443:") - 1),
++              "peer key must start with the scheme, host and port");
+   curlx_safefree(key1);
+   curlx_safefree(key2);
+ 
diff --git a/curl-CVE-2026-111951.patch b/curl-CVE-2026-111951.patch
new file mode 100644
index 0000000..b2cabd3
--- /dev/null
+++ b/curl-CVE-2026-111951.patch
@@ -0,0 +1,116 @@
+CVE-2026-111951: curl -OJ truncate without filename
+https://github.com/curl/curl/commit/631ed306872956f86617df9b5664614e8a2dee54
+
+diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c
+index bd84606..2803f6f 100644
+--- a/src/tool_cb_hdr.c
++++ b/src/tool_cb_hdr.c
+@@ -402,10 +402,12 @@ static size_t content_disposition(const char *str, const char *end,
+       }
+       break;
+     }
+-    if(!outs->stream && !tool_create_output_file(outs, per->config))
+-      return CURL_WRITEFUNC_ERROR;
+-    if(tool_write_headers(&per->hdrcbdata, outs->stream))
+-      return CURL_WRITEFUNC_ERROR;
++    /* No usable filename in this header. Do not create the output file
++       yet: a later Content-Disposition header may still provide a name, and
++       opening the URL-derived name here would truncate an existing file
++       that -J is meant to leave alone. The file is created once the body
++       arrives (or at the end of the transfer) and any buffered headers are
++       written then. */
+   } /* content-disposition handling */
+ 
+   if(hdrcbdata->honor_cd_filename &&
+diff --git a/src/tool_operate.c b/src/tool_operate.c
+index b5b3d6a..25d0ae4 100644
+--- a/src/tool_operate.c
++++ b/src/tool_operate.c
+@@ -676,6 +676,10 @@ static CURLcode post_output_handling(struct per_transfer *per,
+     curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &cond_unmet);
+     if(!cond_unmet && !tool_create_output_file(outs, config))
+       return CURLE_WRITE_ERROR;
++    /* write headers buffered while waiting for a -J filename */
++    if(outs->stream && per->hdrcbdata.headlist &&
++       tool_write_headers(&per->hdrcbdata, outs->stream))
++      return CURLE_WRITE_ERROR;
+   }
+ 
+   if(!outs->regular_file && outs->stream && !outs->out_null) {
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index c96880f..8357854 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -1732,6 +1732,7 @@ TESTCASES = \
+   test1714 \
+   test1715 \
+   test1716 \
++  test1718 \
+   test1720 \
+   test1721 \
+   test1722 \
+diff --git a/tests/data/test1718 b/tests/data/test1718
+new file mode 100644
+index 0000000..c4826f3
+--- /dev/null
++++ b/tests/data/test1718
+@@ -0,0 +1,59 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++HTTP
++HTTP GET
++-J
++</keywords>
++</info>
++
++<reply>
++<data nocheck="yes">
++HTTP/1.1 200 OK
++Content-Disposition: inline
++Content-Disposition: attachment; filename="name%TESTNUMBER"
++Content-Length: 8
++
++PAYLOAD
++</data>
++<data2 nocheck="yes">
++HTTP/1.1 200 OK
++Content-Disposition: inline
++Content-Length: 0
++
++</data2>
++</reply>
++
++# Client-side
++<client>
++<server>
++http
++</server>
++<name>
++HTTP GET -OJi, filename-less Content-Disposition first
++</name>
++<command option="no-output,no-include">
++http://%HOSTIP:%HTTPPORT/%TESTNUMBER0002 http://%HOSTIP:%HTTPPORT/name%TESTNUMBER -Ji -O -O --output-dir %LOGDIR
++</command>
++<file name="%LOGDIR/name%TESTNUMBER">
++initial content
++</file>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++<errorcode>
++23
++</errorcode>
++<file name="%LOGDIR/name%TESTNUMBER">
++initial content
++</file>
++<file2 name="%LOGDIR/%TESTNUMBER0002">
++HTTP/1.1 200 OK
++Content-Disposition: inline
++Content-Length: 0
++
++</file2>
++</verify>
++</testcase>
diff --git a/curl-CVE-2026-111952.patch b/curl-CVE-2026-111952.patch
new file mode 100644
index 0000000..827573a
--- /dev/null
+++ b/curl-CVE-2026-111952.patch
@@ -0,0 +1,32 @@
+CVE-2026-111952: OpenSSL provider use-after-free again
+https://github.com/curl/curl/commit/2c5f9c8ac0168e6dee7b5738d331f5503cc730bc
+
+diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
+index 947dcfb..66e91cc 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -3341,6 +3341,14 @@ static void ossl_set_cached_x509_store(struct Curl_cfilter *cf,
+   }
+ }
+ 
++#ifdef OPENSSL_HAS_PROVIDERS
++/* CApath certificates loaded under a provider libctx can outlive that libctx
++   when the store is shared with the multi handle. */
++#define USING_PROVIDER(octx) octx->p.libctx
++#else
++#define USING_PROVIDER(x) 0
++#endif
++
+ CURLcode Curl_ssl_setup_x509_store(struct Curl_cfilter *cf,
+                                    struct Curl_easy *data,
+                                    struct ossl_ctx *octx)
+@@ -3357,7 +3365,8 @@ CURLcode Curl_ssl_setup_x509_store(struct Curl_cfilter *cf,
+     conn_config->verifypeer &&
+     !conn_config->ca_info_blob &&
+     !conn_config->CRLfile &&
+-    !conn_config->native_ca_store;
++    !conn_config->native_ca_store &&
++    !USING_PROVIDER(octx);
+ 
+   ERR_set_mark();
+ 
diff --git a/curl-CVE-2026-111954.patch b/curl-CVE-2026-111954.patch
new file mode 100644
index 0000000..3741001
--- /dev/null
+++ b/curl-CVE-2026-111954.patch
@@ -0,0 +1,20 @@
+CVE-2026-111954: upload reader failed redirect UAF
+https://github.com/curl/curl/commit/b5f512609f88d128d7a28ca475e143fedea1d446
+
+diff --git a/lib/transfer.c b/lib/transfer.c
+index 3f0f215..abc7623 100644
+--- a/lib/transfer.c
++++ b/lib/transfer.c
+@@ -590,6 +590,12 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
+   }
+ 
+   data->req.headerbytecount = 0;
++  /* a previous transfer on this handle may have ended with a rewind request
++   * still pending (a follow or auth retry that failed). This is a new
++   * transfer, so drop those readers now instead of letting a later upload
++   * read from them. */
++  data->req.rewind_read = FALSE;
++  Curl_client_reset(data);
+   Curl_headers_cleanup(data);
+   return result;
+ }
diff --git a/curl-conn-reuse-pending-input.patch b/curl-conn-reuse-pending-input.patch
new file mode 100644
index 0000000..f3501b5
--- /dev/null
+++ b/curl-conn-reuse-pending-input.patch
@@ -0,0 +1,129 @@
+Do not reuse an idle connection with unread input (HTTP/1.1 responses shift
+by one, HTTP/2 reuse of a closed connection fails with CURLE_SEND_ERROR).
+Regression in 8.22.0, https://github.com/curl/curl/issues/23621
+https://github.com/curl/curl/commit/ef6b17cf12d4af4dfb2af4f9bc35861772be71c7
+https://github.com/curl/curl/commit/774d3bff38515beb75c6d86c3e0455f0c8da7c9e
+
+diff --git a/lib/conncache.c b/lib/conncache.c
+index 2f759be..1cc53f3 100644
+--- a/lib/conncache.c
++++ b/lib/conncache.c
+@@ -1048,7 +1048,15 @@ bool Curl_cpool_conn_seems_healthy(struct connectdata *conn,
+   DEBUGASSERT(!data->conn);
+   if(cpool_conn_can_be_closed(conn) && cpool_conn_too_old(data, conn, pnow))
+     return FALSE;
+-  if((curlx_ptimediff_ms(pnow, &conn->created) - conn->lastchecked_ms) < 1000)
++
++  /* An idle, non-multiplexed connection must not be reused when it has
++   * input pending (RFC 9112, section 9.2). Check this:
++   * - on a connection that is not in use
++   * - or a connection having its own "is dead" callback
++   * - or the last check was more than a second ago */
++  if(CONN_INUSE(conn) &&
++     !conn->scheme->run->connection_is_dead &&
++     (curlx_ptimediff_ms(pnow, &conn->created) - conn->lastchecked_ms) < 1000)
+     return TRUE;
+ 
+   admin = Curl_get_admin(data);
+@@ -1063,7 +1071,7 @@ bool Curl_cpool_conn_seems_healthy(struct connectdata *conn,
+     Curl_attach_connection(admin, conn, FALSE);
+     healthy = Curl_conn_is_alive(admin, conn, &input_pending);
+     Curl_detach_connection(admin);
+-    if(healthy && input_pending && cpool_conn_can_be_closed(conn) &&
++    if(healthy && input_pending && !CONN_INUSE(conn) &&
+        !Curl_conn_is_multiplex(conn, FIRSTSOCKET)) {
+       /* Non-multiplexed connections without attached transfers should
+        * not have input pending. The input might be a TLS Notify Close,
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index d066f2d..0f4ce61 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -1716,6 +1716,7 @@ TESTCASES = \
+   test1693 \
+   \
+   test1700 \
++  test1701 \
+   test1702 \
+   test1703 \
+   test1704 \
+diff --git a/tests/data/test1701 b/tests/data/test1701
+new file mode 100644
+index 0000000..e4e3d04
+--- /dev/null
++++ b/tests/data/test1701
+@@ -0,0 +1,75 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++HTTP
++HTTP GET
++DELAY
++</keywords>
++</info>
++# Server-side
++<reply>
++# the first response is exactly 60 bytes so that with writedelay the server
++# sends it in three 20 byte writes and the unsolicited second response only
++# starts arriving after the first transfer is complete and the connection
++# has been returned to the pool
++<data nocheck="yes">
++HTTP/1.1 200 OK
++Funny-head: yesyes
++Content-Length: 6
++
++first
++HTTP/1.1 200 OK
++Content-Length: 6
++
++stray
++</data>
++<data2>
++HTTP/1.1 200 OK
++Content-Length: 7
++
++second
++</data2>
++<servercmd>
++writedelay: 150
++</servercmd>
++</reply>
++
++# Client-side
++<client>
++<server>
++http
++</server>
++<name>
++HTTP/1.1 idle connection with unsolicited data is not reused
++</name>
++# --rate 1/s starts the second request 1000 ms after the first one started,
++# which is about 700 ms after the first response completed and the
++# connection went back to the pool, inside the one second window where the
++# pool used to skip the alive check. The stray response has fully arrived
++# about 750 ms in.
++<command option="no-include">
++http://%HOSTIP:%HTTPPORT/%TESTNUMBER http://%HOSTIP:%HTTPPORT/%TESTNUMBER0002 --rate 1/s
++</command>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++<protocol crlf="yes">
++GET /%TESTNUMBER HTTP/1.1
++Host: %HOSTIP:%HTTPPORT
++User-Agent: curl/%VERSION
++Accept: */*
++
++GET /%TESTNUMBER0002 HTTP/1.1
++Host: %HOSTIP:%HTTPPORT
++User-Agent: curl/%VERSION
++Accept: */*
++
++</protocol>
++<stdout>
++first
++second
++</stdout>
++</verify>
++</testcase>
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/curl.git/commitdiff/91253590271094acdd8c7b6196a6e05d4a4a9ebc



More information about the pld-cvs-commit mailing list