curl_global_sslset.3 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2022, 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 7.56" "libcurl Manual"
  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,
  37. CURLSSLBACKEND_GNUTLS = 2,
  38. CURLSSLBACKEND_NSS = 3,
  39. CURLSSLBACKEND_GSKIT = 5,
  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,
  47. CURLSSLBACKEND_BEARSSL = 13
  48. } curl_sslbackend;
  49. CURLsslset curl_global_sslset(curl_sslbackend id,
  50. const char *name,
  51. curl_ssl_backend ***avail);
  52. .fi
  53. .SH DESCRIPTION
  54. This function configures at runtime which SSL backend to use with
  55. libcurl. This function can only be used to select an SSL backend once, and it
  56. must be called \fBbefore\fP \fIcurl_global_init(3)\fP.
  57. The backend can be identified by the \fIid\fP
  58. (e.g. \fBCURLSSLBACKEND_OPENSSL\fP). The backend can also be specified via the
  59. \fIname\fP parameter for a case insensitive match (passing -1 as \fIid\fP). If
  60. both \fIid\fP and \fIname\fP are specified, the \fIname\fP will be ignored.
  61. If neither \fIid\fP nor \fPname\fP are specified, the function will fail with
  62. \fBCURLSSLSET_UNKNOWN_BACKEND\fP and set the \fIavail\fP pointer to the
  63. NULL-terminated list of available backends. The available backends are those
  64. that this particular build of libcurl supports.
  65. Since libcurl 7.60.0, the \fIavail\fP pointer will always be set to the list
  66. of alternatives if non-NULL.
  67. Upon success, the function returns \fBCURLSSLSET_OK\fP.
  68. If the specified SSL backend is not available, the function returns
  69. \fBCURLSSLSET_UNKNOWN_BACKEND\fP and sets the \fIavail\fP pointer to a
  70. NULL-terminated list of available SSL backends. In this case, you may call the
  71. function again to try to select a different backend.
  72. The SSL backend can be set only once. If it has already been set, a subsequent
  73. attempt to change it will result in a \fBCURLSSLSET_TOO_LATE\fP.
  74. This function is thread-safe since libcurl 7.84.0 if
  75. \fIcurl_version_info(3)\fP has the CURL_VERSION_THREADSAFE feature bit set
  76. (most platforms).
  77. If this is not thread-safe, you must not call this function when any other
  78. thread in the program (i.e. a thread sharing the same memory) is running.
  79. This does not just mean no other thread that is using libcurl.
  80. .SH EXAMPLE
  81. .nf
  82. /* choose a specific backend */
  83. curl_global_sslset(CURLSSLBACKEND_WOLFSSL, NULL, NULL);
  84. /* list the available ones */
  85. const curl_ssl_backend **list;
  86. curl_global_sslset((curl_sslbackend)-1, NULL, &list);
  87. for(i = 0; list[i]; i++)
  88. printf("SSL backend #%d: '%s' (ID: %d)\\n",
  89. i, list[i]->name, list[i]->id);
  90. .fi
  91. .SH AVAILABILITY
  92. This function was added in libcurl 7.56.0. Before this version, there was no
  93. support for choosing SSL backends at runtime.
  94. .SH RETURN VALUE
  95. If this function returns \fICURLSSLSET_OK\fP, the backend was successfully
  96. selected.
  97. If the chosen backend is unknown (or support for the chosen backend has not
  98. been compiled into libcurl), the function returns
  99. \fICURLSSLSET_UNKNOWN_BACKEND\fP.
  100. If the backend had been configured previously, or if \fIcurl_global_init(3)\fP
  101. has already been called, the function returns \fICURLSSLSET_TOO_LATE\fP.
  102. If this libcurl was built completely without SSL support, with no backends at
  103. all, this function returns \fICURLSSLSET_NO_BACKENDS\fP.
  104. .SH "SEE ALSO"
  105. .BR curl_global_init "(3), "
  106. .BR libcurl "(3) "