CURLOPT_SSLKEY_BLOB.3 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. .\" generated by cd2nroff 0.1 from CURLOPT_SSLKEY_BLOB.md
  2. .TH CURLOPT_SSLKEY_BLOB 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_SSLKEY_BLOB \- private key for client cert from memory blob
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLKEY_BLOB,
  9. struct curl_blob *blob);
  10. .fi
  11. .SH DESCRIPTION
  12. Pass a pointer to a curl_blob structure, which contains information (pointer
  13. and size) for a private key. Compatible with OpenSSL. The format (like "PEM")
  14. must be specified with \fICURLOPT_SSLKEYTYPE(3)\fP.
  15. If the blob is initialized with the flags member of struct curl_blob set to
  16. CURL_BLOB_COPY, the application does not have to keep the buffer around after
  17. setting this.
  18. This option is an alternative to \fICURLOPT_SSLKEY(3)\fP which instead expects a
  19. filename as input.
  20. .SH DEFAULT
  21. NULL
  22. .SH PROTOCOLS
  23. This functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
  24. This option works only with the following TLS backends:
  25. OpenSSL
  26. .SH EXAMPLE
  27. .nf
  28. extern char *certificateData; /* point to cert */
  29. extern size_t filesize; /* size of cert */
  30. extern char *privateKeyData; /* point to key */
  31. extern size_t privateKeySize; /* size of key */
  32. int main(void)
  33. {
  34. CURL *curl = curl_easy_init();
  35. if(curl) {
  36. CURLcode res;
  37. struct curl_blob blob;
  38. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  39. blob.data = certificateData;
  40. blob.len = filesize;
  41. blob.flags = CURL_BLOB_COPY;
  42. curl_easy_setopt(curl, CURLOPT_SSLCERT_BLOB, &blob);
  43. curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
  44. blob.data = privateKeyData;
  45. blob.len = privateKeySize;
  46. curl_easy_setopt(curl, CURLOPT_SSLKEY_BLOB, &blob);
  47. curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
  48. curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM");
  49. res = curl_easy_perform(curl);
  50. curl_easy_cleanup(curl);
  51. }
  52. }
  53. .fi
  54. .SH AVAILABILITY
  55. Added in curl 7.71.0
  56. .SH RETURN VALUE
  57. Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or
  58. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  59. .SH SEE ALSO
  60. .BR CURLOPT_SSLKEY (3),
  61. .BR CURLOPT_SSLKEYTYPE (3)