CURLOPT_CERTINFO.3 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. .\" generated by cd2nroff 0.1 from CURLOPT_CERTINFO.md
  2. .TH CURLOPT_CERTINFO 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_CERTINFO \- request SSL certificate information
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CERTINFO, long certinfo);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long set to 1 to enable libcurl\(aqs certificate chain info gatherer. With
  12. this enabled, libcurl extracts lots of information and data about the
  13. certificates in the certificate chain used in the SSL connection. This data
  14. may then be retrieved after a transfer using \fIcurl_easy_getinfo(3)\fP and
  15. its option \fICURLINFO_CERTINFO(3)\fP.
  16. .SH DEFAULT
  17. 0
  18. .SH PROTOCOLS
  19. This functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
  20. This option works only with the following TLS backends:
  21. GnuTLS, OpenSSL, Schannel and Secure Transport
  22. .SH EXAMPLE
  23. .nf
  24. int main(void)
  25. {
  26. CURL *curl = curl_easy_init();
  27. if(curl) {
  28. CURLcode res;
  29. curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
  30. /* connect to any HTTPS site, trusted or not */
  31. curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
  32. curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
  33. curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L);
  34. res = curl_easy_perform(curl);
  35. if(!res) {
  36. struct curl_certinfo *ci;
  37. res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci);
  38. if(!res) {
  39. int i;
  40. printf("%d certs!\\n", ci->num_of_certs);
  41. for(i = 0; i < ci->num_of_certs; i++) {
  42. struct curl_slist *slist;
  43. for(slist = ci->certinfo[i]; slist; slist = slist->next)
  44. printf("%s\\n", slist->data);
  45. }
  46. }
  47. }
  48. curl_easy_cleanup(curl);
  49. }
  50. }
  51. .fi
  52. .SH HISTORY
  53. Schannel support added in 7.50.0. Secure Transport support added in 7.79.0.
  54. mbedTLS support added in 8.9.0.
  55. .SH AVAILABILITY
  56. Added in curl 7.19.1
  57. .SH RETURN VALUE
  58. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  59. .SH SEE ALSO
  60. .BR CURLINFO_CAINFO (3),
  61. .BR CURLINFO_CAPATH (3),
  62. .BR CURLINFO_CERTINFO (3),
  63. .BR CURLOPT_CAINFO (3),
  64. .BR CURLOPT_SSL_VERIFYPEER (3)