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

openssl: honor --[no-]alpn|npn command line switch

Disable ALPN or NPN if requested by the user.
parent 8f5a9147
Loading
Loading
Loading
Loading
+36 −27
Original line number Diff line number Diff line
@@ -1667,9 +1667,14 @@ ossl_connect_step1(struct connectdata *conn,
  SSL_CTX_set_options(connssl->ctx, ctx_options);

#ifdef USE_NGHTTP2
  SSL_CTX_set_next_proto_select_cb(connssl->ctx, select_next_proto_cb, conn);
  if(data->set.httpversion == CURL_HTTP_VERSION_2_0) {
    if(data->set.ssl_enable_npn) {
      SSL_CTX_set_next_proto_select_cb(connssl->ctx, select_next_proto_cb,
          conn);
    }

#ifdef HAS_ALPN
    if(data->set.ssl_enable_alpn) {
      protocols[0] = NGHTTP2_PROTO_VERSION_ID_LEN;
      memcpy(&protocols[1], NGHTTP2_PROTO_VERSION_ID,
          NGHTTP2_PROTO_VERSION_ID_LEN);
@@ -1686,7 +1691,9 @@ ossl_connect_step1(struct connectdata *conn,

      infof(data, "ALPN, offering %s, %s\n", NGHTTP2_PROTO_VERSION_ID,
            ALPN_HTTP_1_1);
    }
#endif
  }
#endif

  if(data->set.str[STRING_CERT] || data->set.str[STRING_CERT_TYPE]) {
@@ -1964,6 +1971,7 @@ ossl_connect_step2(struct connectdata *conn, int sockindex)
    /* Sets data and len to negotiated protocol, len is 0 if no protocol was
     * negotiated
     */
    if(data->set.ssl_enable_alpn) {
      SSL_get0_alpn_selected(connssl->handle, &neg_protocol, &len);
      if(len != 0) {
        infof(data, "ALPN, server accepted to use %.*s\n", len, neg_protocol);
@@ -1980,6 +1988,7 @@ ossl_connect_step2(struct connectdata *conn, int sockindex)
      else {
        infof(data, "ALPN, server did not agree to a protocol\n");
      }
    }
#endif

    return CURLE_OK;