CURLOPT_SSL_VERIFYPEER(3)
π CURLOPT_SSL_VERIFYPEER(3) β like, the peer's SSL certificate check π
okay bestie, welcome to the CURLOPT_SSL_VERIFYPEER page from the Library Functions Manual β no cap, this is the one that decides whether curl actually trusts the server it's talking to. sit down, grab a lil snack, we're doing TLS trust today π
β¨ NAME β¨
CURLOPT_SSL_VERIFYPEER β verify the peer's SSL certificate π₯
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYPEER, long verify);
literally just pass a long, that's the whole vibe π«Ά
π¦ DESCRIPTION π¦
So. You pass a long as the parameter and that turns the thing on or off. iconic behavior tbh.
This option decides whether curl verifies the authenticity of the peer's certificate. A value of 1 means curl verifies π. 0 (zero) means it does not π.
Here's the lore: when negotiating a TLS or SSL connection, the server sends a certificate that indicates its identity. curl then checks whether that certificate is authentic β i.e. that you can trust that the server is who the certificate says it is. This trust is based on a chain of digital signatures, rooted in certification authority (CA) certificates you supply. curl uses a default bundle of CA certificates (the path for that is determined at build time) and you can specify alternate certificates with the CURLOPT_CAINFO(3) option or the CURLOPT_CAPATH(3) option. king behavior honestly π
When CURLOPT_SSL_VERIFYPEER(3) is enabled, and the verification fails to prove that the certificate is signed by a CA, the connection fails. like, it's not gonna happen, sorry not sorry π
When this option is disabled (set to zero), the CA certificates are not loaded and the peer certificate verification is simply skipped. zero thoughts, head empty β¨
Authenticating the certificate is not enough to be sure about the server, tho. You typically also want to ensure that the server is the server you mean to be talking to. Use CURLOPT_SSL_VERIFYHOST(3) for that π§. The check that the host name in the certificate is valid for the hostname you are connecting to is done independently of the CURLOPT_SSL_VERIFYPEER(3) option β they're two separate girlies doing two separate jobs.
π¨ WARNING: disabling verification of the certificate allows bad guys to man-in-the-middle the communication without you knowing it π Disabling verification makes the communication insecure. Just having encryption on a transfer is not enough as you cannot be sure that you are communicating with the correct end-point. like, encryption without identity verification is giving "locked door, unknown address" bestie πͺπ
Also β and this is the part people forget β when libcurl uses secure protocols it trusts responses and allows for example HSTS and Alt-Svc information to be stored and used subsequently. Disabling certificate verification can make libcurl trust and use such information from malicious servers. π«£ so yeah, it's not just one request, it's future-you's problem too.
π DEFAULT π
1 - enabled β
(that's the good one, keep it π)
π PROTOCOLS π
This functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. πΈ
All TLS backends support this option. every single one, fr fr π
π EXAMPLE π
okay here's the whole thing in action:
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Set the default value: strict certificate check please */
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_perform(curl);
}
}
strict certificate check please β¨ she said what she said π
β AVAILABILITY β
Added in curl 7.4.2 β an elder icon, honestly π
π RETURN VALUE π
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK π, non-zero means an error occurred π β see libcurl-errors(3) for the whole receipts list.
π₯ SEE ALSO π₯
CURLINFO_CAINFO(3)CURLINFO_CAPATH(3)CURLOPT_CAINFO(3)CURLOPT_PROXY_SSL_VERIFYHOST(3)CURLOPT_PROXY_SSL_VERIFYPEER(3)CURLOPT_SSL_VERIFYHOST(3)
go read them, they're all part of the same friend group π«Ά
anyway that's the whole page, brought to you by libcurl, version/date 2026-10-12 β CURLOPT_SSL_VERIFYPEER(3) out, stay verified bestie, don't be a man-in-the-middle ππ¦β¨
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms