From: Daniel Stenberg Date: Thu, 31 Mar 2022 12:21:01 +0000 (+0200) Subject: vtls: use a generic "ALPN, server accepted" message X-Git-Tag: curl-7_83_0~86 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=34ebf3f90de4d11908bc1c07a04bb3e70882e890;p=thirdparty%2Fcurl.git vtls: use a generic "ALPN, server accepted" message Closes #8657 --- diff --git a/lib/vtls/bearssl.c b/lib/vtls/bearssl.c index a5c79bdd45..91f4416e8f 100644 --- a/lib/vtls/bearssl.c +++ b/lib/vtls/bearssl.c @@ -869,7 +869,7 @@ static CURLcode bearssl_connect_step3(struct Curl_easy *data, protocol = br_ssl_engine_get_selected_protocol(&backend->ctx.eng); if(protocol) { - infof(data, "ALPN, server accepted to use %s", protocol); + infof(data, VTLS_INFOF_ALPN_ACCEPTED_1STR, protocol); #ifdef USE_HTTP2 if(!strcmp(protocol, ALPN_H2)) diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index 48c53efd74..5a4a9db0a7 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -1263,8 +1263,8 @@ Curl_gtls_verifyserver(struct Curl_easy *data, if(conn->bits.tls_enable_alpn) { rc = gnutls_alpn_get_selected_protocol(session, &proto); if(rc == 0) { - infof(data, "ALPN, server accepted to use %.*s", proto.size, - proto.data); + infof(data, VTLS_INFOF_ALPN_ACCEPTED_LEN_1STR, proto.size, + proto.data); #ifdef USE_HTTP2 if(proto.size == ALPN_H2_LENGTH && diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c index dbe721a4af..d6bed0485b 100644 --- a/lib/vtls/mbedtls.c +++ b/lib/vtls/mbedtls.c @@ -813,7 +813,7 @@ mbed_connect_step2(struct Curl_easy *data, struct connectdata *conn, const char *next_protocol = mbedtls_ssl_get_alpn_protocol(&backend->ssl); if(next_protocol) { - infof(data, "ALPN, server accepted to use %s", 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) && diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c index 5501b0845d..f569ed4d9e 100644 --- a/lib/vtls/nss.c +++ b/lib/vtls/nss.c @@ -866,7 +866,7 @@ static void HandshakeCallback(PRFileDesc *sock, void *arg) return; #ifdef SSL_ENABLE_ALPN case SSL_NEXT_PROTO_SELECTED: - infof(data, "ALPN, server accepted to use %.*s", buflen, buf); + infof(data, VTLS_INFOF_ALPN_ACCEPTED_LEN_1STR, buflen, buf); break; #endif case SSL_NEXT_PROTO_NEGOTIATED: diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 3ee565e644..658907fc78 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -3457,7 +3457,7 @@ static CURLcode ossl_connect_step2(struct Curl_easy *data, unsigned int len; SSL_get0_alpn_selected(backend->handle, &neg_protocol, &len); if(len) { - infof(data, "ALPN, server accepted to use %.*s", len, neg_protocol); + infof(data, VTLS_INFOF_ALPN_ACCEPTED_LEN_1STR, len, neg_protocol); #ifdef USE_HTTP2 if(len == ALPN_H2_LENGTH && diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c index a93702f587..16970b7c36 100644 --- a/lib/vtls/rustls.c +++ b/lib/vtls/rustls.c @@ -412,14 +412,14 @@ cr_set_negotiated_alpn(struct Curl_easy *data, struct connectdata *conn, #ifdef USE_HTTP2 if(len == ALPN_H2_LENGTH && 0 == memcmp(ALPN_H2, protocol, len)) { - infof(data, "ALPN, negotiated h2"); + infof(data, VTLS_INFOF_ALPN_ACCEPTED_1STR, ALPN_H2); conn->negnpn = CURL_HTTP_VERSION_2; } else #endif if(len == ALPN_HTTP_1_1_LENGTH && 0 == memcmp(ALPN_HTTP_1_1, protocol, len)) { - infof(data, "ALPN, negotiated http/1.1"); + infof(data, VTLS_INFOF_ALPN_ACCEPTED_1STR, ALPN_HTTP_1_1); conn->negnpn = CURL_HTTP_VERSION_1_1; } else { diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index 2246e296ca..003b524a53 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -1416,7 +1416,7 @@ schannel_connect_step3(struct Curl_easy *data, struct connectdata *conn, if(alpn_result.ProtoNegoStatus == SecApplicationProtocolNegotiationStatus_Success) { - infof(data, "schannel: ALPN, server accepted to use %.*s", + infof(data, VTLS_INFOF_ALPN_ACCEPTED_LEN_1STR, alpn_result.ProtocolIdSize, alpn_result.ProtocolId); #ifdef USE_HTTP2 diff --git a/lib/vtls/vtls.h b/lib/vtls/vtls.h index 24d4225dd1..6bd1e0dcd3 100644 --- a/lib/vtls/vtls.h +++ b/lib/vtls/vtls.h @@ -34,10 +34,16 @@ struct ssl_connect_data; #define SSLSUPP_TLS13_CIPHERSUITES (1<<5) /* supports TLS 1.3 ciphersuites */ #define SSLSUPP_CAINFO_BLOB (1<<6) +#define ALPN_ACCEPTED "ALPN: server accepted " + #define VTLS_INFOF_NO_ALPN \ "ALPN: server did not agree on a protocol. Uses default." #define VTLS_INFOF_ALPN_OFFER_1STR \ "ALPN: offers %s" +#define VTLS_INFOF_ALPN_ACCEPTED_1STR \ + ALPN_ACCEPTED "%s" +#define VTLS_INFOF_ALPN_ACCEPTED_LEN_1STR \ + ALPN_ACCEPTED "%.*s" struct Curl_ssl { /* diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index 73ac948da5..9f99d861d8 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -757,8 +757,7 @@ wolfssl_connect_step2(struct Curl_easy *data, struct connectdata *conn, rc = wolfSSL_ALPN_GetProtocol(backend->handle, &protocol, &protocol_len); if(rc == SSL_SUCCESS) { - infof(data, "ALPN, server accepted to use %.*s", protocol_len, - protocol); + infof(data, VTLS_INFOF_ALPN_ACCEPTED_LEN_1STR, protocol_len, protocol); if(protocol_len == ALPN_HTTP_1_1_LENGTH && !memcmp(protocol, ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH))