]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
schannel: enable ALPN with MinGW, fix ALPN for UWP builds
authorViktor Szakats <commit@vsz.me>
Tue, 18 Feb 2025 22:30:54 +0000 (23:30 +0100)
committerViktor Szakats <commit@vsz.me>
Wed, 19 Feb 2025 10:27:01 +0000 (11:27 +0100)
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

CMakeLists.txt
lib/vtls/schannel.c

index 8167dd59525231c15e42068247b84b99607aead7..ab938816c1d98dc886e634dc0d62082fea573151 100644 (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)
index 4e6ed052d7645adbf8932d8f7c5f7bf92dc73de8..24a8f68a477c8bd79c6b153edaa36cab126b8223 100644 (file)
 
 /* 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