CURLOPT_SSL_ENABLE_ALPN(3)

πŸ’… CURLOPT_SSL_ENABLE_ALPN β€” it's giving "let's negotiate, bestie" ✨

okay so real quick, this page lives in the Library Functions Manual, and it's all about CURLOPT_SSL_ENABLE_ALPN, which stands for Application Layer Protocol Negotiation (yes the whole thing, no cap 🫢).


🌸 NAME 🌸

CURLOPT_SSL_ENABLE_ALPN β€” Application Layer Protocol Negotiation, aka the little handshake conversation that decides what protocol y'all are actually gonna speak πŸ’¬


πŸŽ€ SYNOPSIS πŸŽ€

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_ENABLE_ALPN, long npn);

✨ DESCRIPTION ✨

So like, you pass a long as the parameter, and it's either 0 or 1 β€” 1 means enable, 0 means disable, that's the whole vibe check πŸ”₯

This option enables/disables ALPN in the SSL handshake (but only if the SSL backend libcurl is built to use actually supports it, iykyk β€” if it doesn't, well, nothing happens πŸ™ˆ). And what's the point? It can be used to negotiate http2. that's the main character move right there πŸ‘‘


πŸ’– DEFAULT πŸ’–

1, enabled β€” yeah she's on by default, slaying from the start πŸ’…


πŸ¦‹ PROTOCOLS πŸ¦‹

This functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. β€” literally the whole TLS friend group 🌈

All TLS backends support this option. all of them. no exceptions. slay πŸ’œ


🌸 EXAMPLE 🌸

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
    curl_easy_setopt(curl, CURLOPT_SSL_ENABLE_ALPN, 0L);
    result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
}

(not us turning ALPN off with that 0L β€” bold choice, iconic honestly πŸŽ€)


⭐ AVAILABILITY ⭐

Added in curl 7.36.0 β€” she's been around a minute, respect her legacy πŸ‘‘


🧚 RETURN VALUE 🧚

curl_easy_setopt(3) returns a CURLcode indicating success or error, fr fr.

CURLE_OK (0) means everything was OK πŸ’š β€” and non-zero means an error occurred 😭, so go see libcurl-errors(3) for the whole breakdown.


🫢 SEE ALSO 🫢

go read those too bestie, they're lowkey related πŸ’–


mwah πŸ’‹ β€” this page is from libcurl, dated 2026-10-12, and the page itself is CURLOPT_SSL_ENABLE_ALPN(3). now go negotiate some protocols, you got this πŸ¦‹βœ¨

πŸ“¦ where this page comes from