curl_global_sslset.3 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. .\" generated by cd2nroff 0.1 from curl_global_sslset.md
  2. .TH curl_global_sslset 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_global_sslset \- select SSL backend to use
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLsslset curl_global_sslset(curl_sslbackend id,
  9. const char *name,
  10. const curl_ssl_backend ***avail);
  11. .fi
  12. .SH DESCRIPTION
  13. This function configures at runtime which SSL backend to use with
  14. libcurl. This function can only be used to select an SSL backend once, and it
  15. must be called \fBbefore\fP \fIcurl_global_init(3)\fP.
  16. The backend can be identified by the \fIid\fP
  17. (e.g. \fBCURLSSLBACKEND_OPENSSL\fP). The backend can also be specified via the
  18. \fIname\fP parameter for a case insensitive match (passing
  19. \fBCURLSSLBACKEND_NONE\fP as \fIid\fP). If both \fIid\fP and \fIname\fP are
  20. specified, the \fIname\fP is ignored.
  21. If neither \fIid\fP nor \fIname\fP are specified, the function fails with
  22. \fBCURLSSLSET_UNKNOWN_BACKEND\fP and set the \fIavail\fP pointer to the
  23. NULL\-terminated list of available backends. The available backends are those
  24. that this particular build of libcurl supports.
  25. Since libcurl 7.60.0, the \fIavail\fP pointer is always set to the list of
  26. alternatives if non\-NULL.
  27. Upon success, the function returns \fBCURLSSLSET_OK\fP.
  28. If the specified SSL backend is not available, the function returns
  29. \fBCURLSSLSET_UNKNOWN_BACKEND\fP and sets the \fIavail\fP pointer to a
  30. NULL\-terminated list of available SSL backends. In this case, you may call the
  31. function again to try to select a different backend.
  32. The SSL backend can be set only once. If it has already been set, a subsequent
  33. attempt to change it results in a \fBCURLSSLSET_TOO_LATE\fP getting returned.
  34. This function is thread\-safe since libcurl 7.84.0 if
  35. \fIcurl_version_info(3)\fP has the CURL_VERSION_THREADSAFE feature bit set
  36. (most platforms).
  37. If this is not thread\-safe, you must not call this function when any other
  38. thread in the program (i.e. a thread sharing the same memory) is running.
  39. This does not just mean no other thread that is using libcurl.
  40. .SH OpenSSL
  41. The name "OpenSSL" is used for all versions of OpenSSL and its associated
  42. forks/flavors in this function. OpenSSL, BoringSSL, LibreSSL, quictls and
  43. AmiSSL are all supported by libcurl, but in the eyes of
  44. \fIcurl_global_sslset(3)\fP they are all just "OpenSSL". They all mostly
  45. provide the same API.
  46. \fIcurl_version_info(3)\fP can return more specific info about the exact
  47. OpenSSL flavor and version number is use.
  48. .SH struct
  49. .nf
  50. typedef struct {
  51. curl_sslbackend id;
  52. const char *name;
  53. } curl_ssl_backend;
  54. typedef enum {
  55. CURLSSLBACKEND_NONE = 0,
  56. CURLSSLBACKEND_OPENSSL = 1, /* or one of its forks */
  57. CURLSSLBACKEND_GNUTLS = 2,
  58. CURLSSLBACKEND_NSS = 3,
  59. CURLSSLBACKEND_GSKIT = 5, /* deprecated */
  60. CURLSSLBACKEND_POLARSSL = 6, /* deprecated */
  61. CURLSSLBACKEND_WOLFSSL = 7,
  62. CURLSSLBACKEND_SCHANNEL = 8,
  63. CURLSSLBACKEND_SECURETRANSPORT = 9,
  64. CURLSSLBACKEND_AXTLS = 10, /* deprecated */
  65. CURLSSLBACKEND_MBEDTLS = 11,
  66. CURLSSLBACKEND_MESALINK = 12, /* deprecated */
  67. CURLSSLBACKEND_BEARSSL = 13,
  68. CURLSSLBACKEND_RUSTLS = 14
  69. } curl_sslbackend;
  70. .fi
  71. .SH PROTOCOLS
  72. This functionality affects all supported protocols
  73. .SH EXAMPLE
  74. .nf
  75. int main(void)
  76. {
  77. int i;
  78. /* choose a specific backend */
  79. curl_global_sslset(CURLSSLBACKEND_WOLFSSL, NULL, NULL);
  80. /* list the available ones */
  81. const curl_ssl_backend **list;
  82. curl_global_sslset(CURLSSLBACKEND_NONE, NULL, &list);
  83. for(i = 0; list[i]; i++)
  84. printf("SSL backend #%d: '%s' (ID: %d)\\n",
  85. i, list[i]->name, list[i]->id);
  86. }
  87. .fi
  88. .SH AVAILABILITY
  89. Added in curl 7.56.0
  90. .SH RETURN VALUE
  91. If this function returns \fICURLSSLSET_OK\fP, the backend was successfully
  92. selected.
  93. If the chosen backend is unknown (or support for the chosen backend has not
  94. been compiled into libcurl), the function returns
  95. \fICURLSSLSET_UNKNOWN_BACKEND\fP.
  96. If the backend had been configured previously, or if \fIcurl_global_init(3)\fP
  97. has already been called, the function returns \fICURLSSLSET_TOO_LATE\fP.
  98. If this libcurl was built completely without SSL support, with no backends at
  99. all, this function returns \fICURLSSLSET_NO_BACKENDS\fP.
  100. .SH SEE ALSO
  101. .BR curl_global_init (3),
  102. .BR libcurl (3)