curl_global_sslset.3 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .TH curl_global_sslset 3 "15 July 2017" "libcurl" "libcurl"
  25. .SH NAME
  26. curl_global_sslset - Select SSL backend to use with libcurl
  27. .SH SYNOPSIS
  28. .nf
  29. #include <curl/curl.h>
  30. typedef struct {
  31. curl_sslbackend id;
  32. const char *name;
  33. } curl_ssl_backend;
  34. typedef enum {
  35. CURLSSLBACKEND_NONE = 0,
  36. CURLSSLBACKEND_OPENSSL = 1, /* or one of its forks */
  37. CURLSSLBACKEND_GNUTLS = 2,
  38. CURLSSLBACKEND_NSS = 3,
  39. CURLSSLBACKEND_GSKIT = 5, /* deprecated */
  40. CURLSSLBACKEND_POLARSSL = 6, /* deprecated */
  41. CURLSSLBACKEND_WOLFSSL = 7,
  42. CURLSSLBACKEND_SCHANNEL = 8,
  43. CURLSSLBACKEND_SECURETRANSPORT = 9,
  44. CURLSSLBACKEND_AXTLS = 10, /* deprecated */
  45. CURLSSLBACKEND_MBEDTLS = 11,
  46. CURLSSLBACKEND_MESALINK = 12, /* deprecated */
  47. CURLSSLBACKEND_BEARSSL = 13,
  48. CURLSSLBACKEND_RUSTLS = 14
  49. } curl_sslbackend;
  50. CURLsslset curl_global_sslset(curl_sslbackend id,
  51. const char *name,
  52. curl_ssl_backend ***avail);
  53. .fi
  54. .SH DESCRIPTION
  55. This function configures at runtime which SSL backend to use with
  56. libcurl. This function can only be used to select an SSL backend once, and it
  57. must be called \fBbefore\fP \fIcurl_global_init(3)\fP.
  58. The backend can be identified by the \fIid\fP
  59. (e.g. \fBCURLSSLBACKEND_OPENSSL\fP). The backend can also be specified via the
  60. \fIname\fP parameter for a case insensitive match (passing -1 as \fIid\fP). If
  61. both \fIid\fP and \fIname\fP are specified, the \fIname\fP is ignored.
  62. If neither \fIid\fP nor \fPname\fP are specified, the function fails with
  63. \fBCURLSSLSET_UNKNOWN_BACKEND\fP and set the \fIavail\fP pointer to the
  64. NULL-terminated list of available backends. The available backends are those
  65. that this particular build of libcurl supports.
  66. Since libcurl 7.60.0, the \fIavail\fP pointer is always set to the list of
  67. alternatives if non-NULL.
  68. Upon success, the function returns \fBCURLSSLSET_OK\fP.
  69. If the specified SSL backend is not available, the function returns
  70. \fBCURLSSLSET_UNKNOWN_BACKEND\fP and sets the \fIavail\fP pointer to a
  71. NULL-terminated list of available SSL backends. In this case, you may call the
  72. function again to try to select a different backend.
  73. The SSL backend can be set only once. If it has already been set, a subsequent
  74. attempt to change it results in a \fBCURLSSLSET_TOO_LATE\fP getting returned.
  75. This function is thread-safe since libcurl 7.84.0 if
  76. \fIcurl_version_info(3)\fP has the CURL_VERSION_THREADSAFE feature bit set
  77. (most platforms).
  78. If this is not thread-safe, you must not call this function when any other
  79. thread in the program (i.e. a thread sharing the same memory) is running.
  80. This does not just mean no other thread that is using libcurl.
  81. .SH OpenSSL
  82. The name "OpenSSL" is used for all versions of OpenSSL and its associated
  83. forks/flavors in this function. OpenSSL, BoringSSL, libressl, quictls and
  84. AmiSSL are all supported by libcurl, but in the eyes of
  85. \fIcurl_global_sslset(3)\fP they are all just "OpenSSL". They all mostly
  86. provide the same API.
  87. \fIcurl_version_info(3)\fP can return more specific info about the exact
  88. OpenSSL flavor and version number is use.
  89. .SH EXAMPLE
  90. .nf
  91. /* choose a specific backend */
  92. curl_global_sslset(CURLSSLBACKEND_WOLFSSL, NULL, NULL);
  93. /* list the available ones */
  94. const curl_ssl_backend **list;
  95. curl_global_sslset((curl_sslbackend)-1, NULL, &list);
  96. for(i = 0; list[i]; i++)
  97. printf("SSL backend #%d: '%s' (ID: %d)\\n",
  98. i, list[i]->name, list[i]->id);
  99. .fi
  100. .SH AVAILABILITY
  101. This function was added in libcurl 7.56.0. Before this version, there was no
  102. support for choosing SSL backends at runtime.
  103. .SH RETURN VALUE
  104. If this function returns \fICURLSSLSET_OK\fP, the backend was successfully
  105. selected.
  106. If the chosen backend is unknown (or support for the chosen backend has not
  107. been compiled into libcurl), the function returns
  108. \fICURLSSLSET_UNKNOWN_BACKEND\fP.
  109. If the backend had been configured previously, or if \fIcurl_global_init(3)\fP
  110. has already been called, the function returns \fICURLSSLSET_TOO_LATE\fP.
  111. If this libcurl was built completely without SSL support, with no backends at
  112. all, this function returns \fICURLSSLSET_NO_BACKENDS\fP.
  113. .SH "SEE ALSO"
  114. .BR curl_global_init "(3), "
  115. .BR libcurl "(3) "