From: Daniel Stenberg Date: Thu, 31 Mar 2022 14:04:00 +0000 (+0200) Subject: tls: make mbedtls and NSS check for h2, not nghttp2 X-Git-Tag: curl-7_83_0~83 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7c1acaf61e678ff4f8bd01f161d6c74fc0163f53;p=thirdparty%2Fcurl.git tls: make mbedtls and NSS check for h2, not nghttp2 This makes them able to also negotiate HTTP/2 even when built to use hyper for h2. Closes #8656 --- diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c index d6bed0485b..659fed4e38 100644 --- a/lib/vtls/mbedtls.c +++ b/lib/vtls/mbedtls.c @@ -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 diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c index f569ed4d9e..26e6b48f3f 100644 --- a/lib/vtls/nss.c +++ b/lib/vtls/nss.c @@ -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;