CURLOPT_SSL_VERIFYPEER.3 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. .\" generated by cd2nroff 0.1 from CURLOPT_SSL_VERIFYPEER.md
  2. .TH CURLOPT_SSL_VERIFYPEER 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_SSL_VERIFYPEER \- verify the peer\(aqs SSL certificate
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYPEER, long verify);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long as parameter to enable or disable.
  12. This option determines whether curl verifies the authenticity of the peer\(aqs
  13. certificate. A value of 1 means curl verifies; 0 (zero) means it does not.
  14. When negotiating a TLS or SSL connection, the server sends a certificate
  15. indicating its identity. Curl verifies whether the certificate is authentic,
  16. i.e. that you can trust that the server is who the certificate says it is.
  17. This trust is based on a chain of digital signatures, rooted in certification
  18. authority (CA) certificates you supply. curl uses a default bundle of CA
  19. certificates (the path for that is determined at build time) and you can
  20. specify alternate certificates with the \fICURLOPT_CAINFO(3)\fP option or the
  21. \fICURLOPT_CAPATH(3)\fP option.
  22. When \fICURLOPT_SSL_VERIFYPEER(3)\fP is enabled, and the verification fails to
  23. prove that the certificate is signed by a CA, the connection fails.
  24. When this option is disabled (set to zero), the CA certificates are not loaded
  25. and the peer certificate verification is simply skipped.
  26. Authenticating the certificate is not enough to be sure about the server. You
  27. typically also want to ensure that the server is the server you mean to be
  28. talking to. Use \fICURLOPT_SSL_VERIFYHOST(3)\fP for that. The check that the host
  29. name in the certificate is valid for the hostname you are connecting to is
  30. done independently of the \fICURLOPT_SSL_VERIFYPEER(3)\fP option.
  31. WARNING: disabling verification of the certificate allows bad guys to
  32. man\-in\-the\-middle the communication without you knowing it. Disabling
  33. verification makes the communication insecure. Just having encryption on a
  34. transfer is not enough as you cannot be sure that you are communicating with
  35. the correct end\-point.
  36. When libcurl uses secure protocols it trusts responses and allows for example
  37. HSTS and Alt\-Svc information to be stored and used subsequently. Disabling
  38. certificate verification can make libcurl trust and use such information from
  39. malicious servers.
  40. .SH DEFAULT
  41. 1 \- enabled
  42. .SH PROTOCOLS
  43. This functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
  44. All TLS backends support this option.
  45. .SH EXAMPLE
  46. .nf
  47. int main(void)
  48. {
  49. CURL *curl = curl_easy_init();
  50. if(curl) {
  51. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  52. /* Set the default value: strict certificate check please */
  53. curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
  54. curl_easy_perform(curl);
  55. }
  56. }
  57. .fi
  58. .SH AVAILABILITY
  59. Added in curl 7.4.2
  60. .SH RETURN VALUE
  61. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  62. .SH SEE ALSO
  63. .BR CURLINFO_CAINFO (3),
  64. .BR CURLINFO_CAPATH (3),
  65. .BR CURLOPT_CAINFO (3),
  66. .BR CURLOPT_PROXY_SSL_VERIFYHOST (3),
  67. .BR CURLOPT_PROXY_SSL_VERIFYPEER (3),
  68. .BR CURLOPT_SSL_VERIFYHOST (3)