]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tls: make mbedtls and NSS check for h2, not nghttp2
authorDaniel Stenberg <daniel@haxx.se>
Thu, 31 Mar 2022 14:04:00 +0000 (16:04 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 31 Mar 2022 14:04:00 +0000 (16:04 +0200)
This makes them able to also negotiate HTTP/2 even when built to use
hyper for h2.

Closes #8656

lib/vtls/mbedtls.c
lib/vtls/nss.c

index d6bed0485b2565bdfbccb801be032e7da958ca7c..659fed4e386e3a8b9db0a4912ac23f799059cb18 100644 (file)
@@ -144,15 +144,14 @@ static void mbed_debug(void *context, int level, const char *f_name,
 #else
 #endif
 
-/* ALPN for http2? */
-#ifdef USE_NGHTTP2
+/* ALPN for http2 */
+#ifdef USE_HTTP2
 #  undef HAS_ALPN
 #  ifdef MBEDTLS_SSL_ALPN
 #    define HAS_ALPN
 #  endif
 #endif
 
-
 /*
  *  profile
  */
@@ -614,9 +613,9 @@ mbed_connect_step1(struct Curl_easy *data, struct connectdata *conn,
 #ifdef HAS_ALPN
   if(conn->bits.tls_enable_alpn) {
     const char **p = &backend->protocols[0];
-#ifdef USE_NGHTTP2
+#ifdef USE_HTTP2
     if(data->state.httpwant >= CURL_HTTP_VERSION_2)
-      *p++ = NGHTTP2_PROTO_VERSION_ID;
+      *p++ = ALPN_H2;
 #endif
     *p++ = ALPN_HTTP_1_1;
     *p = NULL;
@@ -814,10 +813,9 @@ mbed_connect_step2(struct Curl_easy *data, struct connectdata *conn,
 
     if(next_protocol) {
       infof(data, VTLS_INFOF_ALPN_ACCEPTED_1STR, next_protocol);
-#ifdef USE_NGHTTP2
-      if(!strncmp(next_protocol, NGHTTP2_PROTO_VERSION_ID,
-                  NGHTTP2_PROTO_VERSION_ID_LEN) &&
-         !next_protocol[NGHTTP2_PROTO_VERSION_ID_LEN]) {
+#ifdef USE_HTTP2
+      if(!strncmp(next_protocol, ALPN_H2, ALPN_H2_LEN) &&
+         !next_protocol[ALPN_H2_LEN]) {
         conn->negnpn = CURL_HTTP_VERSION_2;
       }
       else
index f569ed4d9e4d211ac1e91a04aa6ea45ffb1cf646..26e6b48f3fa38c81b173940896193e24c075438b 100644 (file)
@@ -874,7 +874,7 @@ static void HandshakeCallback(PRFileDesc *sock, void *arg)
       break;
     }
 
-#ifdef USE_NGHTTP2
+#ifdef USE_HTTP2
     if(buflen == ALPN_H2_LENGTH &&
        !memcmp(ALPN_H2, buf, ALPN_H2_LENGTH)) {
       conn->negnpn = CURL_HTTP_VERSION_2;