schannel: enable ALPN with MinGW, fix ALPN for UWP builds

ALPN requires mingw-w64 9.0 or newer.

Also fix ALPN-enabled builds for UWP. This assumes that WINE doesn't
support UWP, which seems to be the case when writing this.

Closes #16385
This commit is contained in:
Viktor Szakats 2025-02-18 23:30:54 +01:00
parent 2335cbaa21
commit 397088e8f4
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
2 changed files with 23 additions and 13 deletions

View file

@ -689,7 +689,7 @@ endif()
if(CURL_USE_SCHANNEL)
set(_ssl_enabled ON)
set(USE_SCHANNEL ON) # Windows native SSL/TLS support
set(USE_WINDOWS_SSPI ON) # CURL_USE_SCHANNEL implies CURL_WINDOWS_SSPI
set(USE_WINDOWS_SSPI ON) # CURL_USE_SCHANNEL requires CURL_WINDOWS_SSPI
if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "schannel")
set(_valid_default_ssl_backend TRUE)
@ -2134,7 +2134,7 @@ curl_add_if("SPNEGO" NOT CURL_DISABLE_NEGOTIATE_AUTH AND
(HAVE_GSSAPI OR USE_WINDOWS_SSPI))
curl_add_if("Kerberos" NOT CURL_DISABLE_KERBEROS_AUTH AND
(HAVE_GSSAPI OR USE_WINDOWS_SSPI))
curl_add_if("NTLM" NOT (CURL_DISABLE_NTLM) AND
curl_add_if("NTLM" NOT CURL_DISABLE_NTLM AND
(_use_curl_ntlm_core OR USE_WINDOWS_SSPI))
curl_add_if("TLS-SRP" USE_TLS_SRP)
curl_add_if("HTTP2" USE_NGHTTP2)

View file

@ -74,10 +74,11 @@
/* ALPN requires version 8.1 of the Windows SDK, which was
shipped with Visual Studio 2013, aka _MSC_VER 1800:
https://technet.microsoft.com/en-us/library/hh831771%28v=ws.11%29.aspx
https://technet.microsoft.com/en-us/library/hh831771%28v=ws.11%29.aspx
Or mingw-w64 9.0 or upper.
*/
#if defined(_MSC_VER) && (_MSC_VER >= 1800) && !defined(_USING_V110_SDK71_)
#if (defined(__MINGW32__) && __MINGW64_VERSION_MAJOR >= 9) || \
(defined(_MSC_VER) && (_MSC_VER >= 1800) && !defined(_USING_V110_SDK71_))
# define HAS_ALPN_SCHANNEL
#endif
@ -904,17 +905,26 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
"connect to some servers due to lack of SNI, algorithms, etc.");
}
{
#ifdef HAS_ALPN_SCHANNEL
/* ALPN is only supported on Windows 8.1 / Server 2012 R2 and above.
Also it does not seem to be supported for WINE, see curl bug #983. */
backend->use_alpn = connssl->alpn &&
!GetProcAddress(GetModuleHandle(TEXT("ntdll")),
"wine_get_version") &&
curlx_verify_windows_version(6, 3, 0, PLATFORM_WINNT,
VERSION_GREATER_THAN_EQUAL);
bool wine;
#ifdef CURL_WINDOWS_UWP
/* GetModuleHandle() not available for UWP.
Assume no WINE because WINE has no UWP support. */
wine = FALSE;
#else
backend->use_alpn = FALSE;
wine = !!GetProcAddress(GetModuleHandle(TEXT("ntdll")),
"wine_get_version");
#endif
/* ALPN is only supported on Windows 8.1 / Server 2012 R2 and above.
Also it does not seem to be supported for WINE, see curl bug #983. */
backend->use_alpn = connssl->alpn && !wine &&
curlx_verify_windows_version(6, 3, 0, PLATFORM_WINNT,
VERSION_GREATER_THAN_EQUAL);
#else
backend->use_alpn = FALSE;
#endif
}
#ifdef _WIN32_WCE
#ifdef HAS_MANUAL_VERIFY_API