CURLOPT_SOCKS5_AUTH(3)

πŸ’… CURLOPT_SOCKS5_AUTH β€” like, the whole manual page, bestie

Okay so this is CURLOPT_SOCKS5_AUTH(3) from the libcurl Library Functions Manual and it's literally all about which auth methods your SOCKS5 proxy is allowed to use 🧦✨


✨ NAME ✨

CURLOPT_SOCKS5_AUTH β€” methods for SOCKS5 proxy authentication 🫢


🌸 SYNOPSIS 🌸

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKS5_AUTH, long bitmask);

πŸ¦‹ DESCRIPTION πŸ¦‹

So you pass a long as the parameter, right? And it gets set to a bitmask, and that bitmask tells libcurl which authentication method(s) are allowed for SOCKS5 proxy authentication. That's it, that's the whole vibe πŸ’…

The only supported flags are:

  • CURLAUTH_BASIC β€” allows username/password authentication πŸ”‘
  • CURLAUTH_GSSAPI β€” allows GSS-API authentication 🎫
  • CURLAUTH_NONE β€” allows no authentication, like, at all πŸ™ˆ

And if you actually want to set the real username and password? That's a whole different option, bestie β€” use CURLOPT_PROXYUSERPWD(3) for that ✨


πŸŽ€ DEFAULT πŸŽ€

CURLAUTH_BASIC | CURLAUTH_GSSAPI

That's the starting point, no cap πŸ‘‘


🌈 PROTOCOLS 🌈

This functionality affects all supported protocols β€” every single one, she's versatile like that πŸ’–


⭐ EXAMPLE ⭐

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");

    /* request to use a SOCKS5 proxy */
    curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://user:pass@myproxy.com");

    /* enable username/password authentication only */
    curl_easy_setopt(curl, CURLOPT_SOCKS5_AUTH, CURLAUTH_BASIC);

    /* Perform the request */
    curl_easy_perform(curl);
  }
}

Look at her go 😭 so clean, so iconic πŸ’…


🧚 HISTORY 🧚

The CURLAUTH_* macros became long types in 7.26.0. Before that version? You had to do a long cast when passing them to curl_easy_setopt(3). Dark times, fr fr πŸ’€


πŸ“ AVAILABILITY πŸ“

Added in curl 7.55.0 ✨ (she's not ancient, but she's been around πŸ’œ)


πŸ”₯ RETURN VALUE πŸ”₯

curl_easy_setopt(3) returns a CURLcode indicating success or error πŸ‘‘

  • CURLE_OK (0) β€” means everything was OK, we ate, no notes πŸŽ€
  • non-zero β€” means an error occurred 😭 go check libcurl-errors(3) for what went wrong

πŸ’œ SEE ALSO πŸ’œ

Go read those too, iykyk πŸ¦‹


libcurl Β· 2026-10-12 Β· CURLOPT_SOCKS5_AUTH(3) β€” and that's the whole page, bestie, you're welcome, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from