gtls: honor --[no-]alpn command line switch
Disable ALPN if requested by the user.
This commit is contained in:
committed by
Daniel Stenberg
parent
82a4d537c3
commit
8f5a9147be
@@ -570,6 +570,8 @@ gtls_connect_step1(struct connectdata *conn,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_ALPN
|
#ifdef HAS_ALPN
|
||||||
|
if(data->set.httpversion == CURL_HTTP_VERSION_2_0) {
|
||||||
|
if(data->set.ssl_enable_alpn) {
|
||||||
protocols[0].data = NGHTTP2_PROTO_VERSION_ID;
|
protocols[0].data = NGHTTP2_PROTO_VERSION_ID;
|
||||||
protocols[0].size = NGHTTP2_PROTO_VERSION_ID_LEN;
|
protocols[0].size = NGHTTP2_PROTO_VERSION_ID_LEN;
|
||||||
protocols[1].data = ALPN_HTTP_1_1;
|
protocols[1].data = ALPN_HTTP_1_1;
|
||||||
@@ -577,6 +579,11 @@ gtls_connect_step1(struct connectdata *conn,
|
|||||||
gnutls_alpn_set_protocols(session, protocols, protocols_size, 0);
|
gnutls_alpn_set_protocols(session, protocols, protocols_size, 0);
|
||||||
infof(data, "ALPN, offering %s, %s\n", NGHTTP2_PROTO_VERSION_ID,
|
infof(data, "ALPN, offering %s, %s\n", NGHTTP2_PROTO_VERSION_ID,
|
||||||
ALPN_HTTP_1_1);
|
ALPN_HTTP_1_1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
infof(data, "SSL, can't negotiate HTTP/2.0 without ALPN\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(rc != GNUTLS_E_SUCCESS) {
|
if(rc != GNUTLS_E_SUCCESS) {
|
||||||
@@ -867,9 +874,11 @@ gtls_connect_step3(struct connectdata *conn,
|
|||||||
infof(data, "\t MAC: %s\n", ptr);
|
infof(data, "\t MAC: %s\n", ptr);
|
||||||
|
|
||||||
#ifdef HAS_ALPN
|
#ifdef HAS_ALPN
|
||||||
|
if(data->set.ssl_enable_alpn) {
|
||||||
rc = gnutls_alpn_get_selected_protocol(session, &proto);
|
rc = gnutls_alpn_get_selected_protocol(session, &proto);
|
||||||
if(rc == 0) {
|
if(rc == 0) {
|
||||||
infof(data, "ALPN, server accepted to use %.*s\n", proto.size, proto.data);
|
infof(data, "ALPN, server accepted to use %.*s\n", proto.size,
|
||||||
|
proto.data);
|
||||||
|
|
||||||
if(proto.size == NGHTTP2_PROTO_VERSION_ID_LEN &&
|
if(proto.size == NGHTTP2_PROTO_VERSION_ID_LEN &&
|
||||||
memcmp(NGHTTP2_PROTO_VERSION_ID, proto.data,
|
memcmp(NGHTTP2_PROTO_VERSION_ID, proto.data,
|
||||||
@@ -884,6 +893,7 @@ gtls_connect_step3(struct connectdata *conn,
|
|||||||
else {
|
else {
|
||||||
infof(data, "ALPN, server did not agree to a protocol\n");
|
infof(data, "ALPN, server did not agree to a protocol\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
conn->ssl[sockindex].state = ssl_connection_complete;
|
conn->ssl[sockindex].state = ssl_connection_complete;
|
||||||
|
|||||||
Reference in New Issue
Block a user