Commit 8f5a9147 authored by Fabian Frank's avatar Fabian Frank Committed by Daniel Stenberg
Browse files

gtls: honor --[no-]alpn command line switch

Disable ALPN if requested by the user.
parent 82a4d537
Loading
Loading
Loading
Loading
+31 −21
Original line number Diff line number Diff line
@@ -570,6 +570,8 @@ gtls_connect_step1(struct connectdata *conn,
#endif

#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].size = NGHTTP2_PROTO_VERSION_ID_LEN;
      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);
      infof(data, "ALPN, offering %s, %s\n", NGHTTP2_PROTO_VERSION_ID,
            ALPN_HTTP_1_1);
    }
    else {
      infof(data, "SSL, can't negotiate HTTP/2.0 without ALPN\n");
    }
  }
#endif

  if(rc != GNUTLS_E_SUCCESS) {
@@ -867,9 +874,11 @@ gtls_connect_step3(struct connectdata *conn,
  infof(data, "\t MAC: %s\n", ptr);

#ifdef HAS_ALPN
  if(data->set.ssl_enable_alpn) {
    rc = gnutls_alpn_get_selected_protocol(session, &proto);
    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 &&
        memcmp(NGHTTP2_PROTO_VERSION_ID, proto.data,
@@ -884,6 +893,7 @@ gtls_connect_step3(struct connectdata *conn,
    else {
      infof(data, "ALPN, server did not agree to a protocol\n");
    }
  }
#endif

  conn->ssl[sockindex].state = ssl_connection_complete;