c++openssllibcurlalpn

How to disable ALPN extension?


As per this, in libcurl, the CURLOPT_SSL_ENABLE_ALPN option is enabled by default. For a project, I am trying to disable the ALPN extension, as below:

CURLcode res = CURLE_OK;
res = curl_easy_setopt(curl_, CURLOPT_SSL_ENABLE_ALPN, 0L);
if(res == CURLE_OK){
    cout<<"Set CURLOPT_SSL_ENABLE_ALPN to 0L res = "<<res;
}else{
    cout<<"Set CURLOPT_SSL_ENABLE_ALPN to 1L  res = "<<res<<"\t"<<curl_easy_strerror(res);
}

This is throwing me an error:

Set CURLOPT_SSL_ENABLE_ALPN to 1L  res = 48   An unknown option was passed in to libcurl

And, I can see ALPN extension present in TLS handshake, able to see it with Wireshark. How do I disable the ALPN extension? Openssl Version: OpenSSL 1.1.0k Curl Version: 7.67.0


Solution

  • Apparently, if you don't compile with libcurl with HTTP2 support (libnghttp2), it is treating CURLOPT_SSL_ENABLE_ALPN and CURLOPT_SSL_ENABLE_NPN as unknown options, though ALPN and NPN are independent of HTTP2. It was a bug in libcurl. I had reported this behavior at libcurl github repo here, which they fixed it and fix will be available in next release.