CURLOPT_SOCKS5_GSSAPI_NEC(3)

πŸ’… CURLOPT_SOCKS5_GSSAPI_NEC πŸ’…

okay bestie, so this little gem lives in the Library Functions Manual (libcurl section, very demure, very cURL) and it's about SOCKS proxy GSSAPI negotiation protection. i know, i know, the name is giving "I aced the spelling bee" but stay with me, it's actually so simple 🫢


🌸 NAME 🌸

CURLOPT_SOCKS5_GSSAPI_NEC β€” the SOCKS proxy GSSAPI negotiation protection option. literally what it says on the tin, no cap ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKS5_GSSAPI_NEC, long nec);

πŸ’– DESCRIPTION πŸ’–

okay so you pass a long β€” set it to 1 to enable, or 0 to disable. that's the whole vibe check πŸ’…

here's the tea πŸ“: as part of the GSSAPI negotiation, a protection mode gets negotiated. and the RFC 1961 (yes, the actual RFC, section 4.3/4.4 to be specific, iykyk) says it should be protected. but the NEC reference implementation? bestie, it does not do that 😭

so if you enable this option, it lets the protection mode negotiation happen through an unprotected exchange. iconic of it, honestly. so if you're dealing with a server that's not doing the RFC thing, this is your main character option πŸ‘‘


✨ DEFAULT ✨

?

(no really, that's what the manpage says. the default is a mystery, a vibe, a question mark. we love an enigmatic queen πŸ™ˆ)


🌈 PROTOCOLS 🌈

this functionality affects all supported protocols β€” every single one, periodt πŸŽ€


πŸ¦‹ EXAMPLE πŸ¦‹

here's the whole thing in action, bestie:

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_PROXY, "socks5://proxy");
    curl_easy_setopt(curl, CURLOPT_SOCKS5_GSSAPI_NEC, 1L);
    result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
}

see how it sets the URL, then the proxy to socks5://proxy, then flips CURLOPT_SOCKS5_GSSAPI_NEC to 1L? slay. ate. no crumbs πŸ”₯


πŸ’œ AVAILABILITY πŸ’œ

added in curl 7.19.4 β€” an elder icon, but a icon nonetheless πŸ‘‘


⭐ RETURN VALUE ⭐

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

  • CURLE_OK (0) β€” everything was OK, we're so back πŸ’–
  • non-zero β€” an error occurred 😭 see libcurl-errors(3) for the deets

🧚 SEE ALSO 🧚


ngl the "unprotected exchange" bit is a real thing you're opting into here β€” so know what you're doing before you flip it to 1. it's not undefined behaviour, it's just... letting your guard down during negotiation πŸ’€

k bye bestie, this page was brought to you by libcurl, dated 2026-10-12, from the Library Functions Manual β€” go forth and negotiate your protection modes, protected or otherwise πŸŽ€βœ¨πŸ’…

πŸ“¦ where this page comes from