CURLOPT_SSL_CTX_FUNCTION.3 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2018, 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.haxx.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. .\" **************************************************************************
  22. .\"
  23. .TH CURLOPT_SSL_CTX_FUNCTION 3 "August 29, 2018" "libcurl 7.61.1" "curl_easy_setopt options"
  24. .SH NAME
  25. CURLOPT_SSL_CTX_FUNCTION \- SSL context callback for OpenSSL, wolfSSL/CyaSSL or mbedTLS
  26. .SH SYNOPSIS
  27. .nf
  28. #include <curl/curl.h>
  29. CURLcode ssl_ctx_callback(CURL *curl, void *ssl_ctx, void *userptr);
  30. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_CTX_FUNCTION,
  31. ssl_ctx_callback);
  32. .SH DESCRIPTION
  33. This option only works for libcurl powered by OpenSSL, wolfSSL/CyaSSL or
  34. mbedTLS. If libcurl was built against another SSL library this functionality is
  35. absent.
  36. Pass a pointer to your callback function, which should match the prototype
  37. shown above.
  38. This callback function gets called by libcurl just before the initialization
  39. of an SSL connection after having processed all other SSL related options to
  40. give a last chance to an application to modify the behavior of the SSL
  41. initialization. The \fIssl_ctx\fP parameter is actually a pointer to the SSL
  42. library's \fISSL_CTX\fP for OpenSSL or wolfSSL/CyaSSL, and a pointer to
  43. \fImbedtls_ssl_config\fP for mbedTLS. If an error is returned from the callback
  44. no attempt to establish a connection is made and the perform operation will
  45. return the callback's error code. Set the \fIuserptr\fP argument with the
  46. \fICURLOPT_SSL_CTX_DATA(3)\fP option.
  47. This function will get called on all new connections made to a server, during
  48. the SSL negotiation. The \fIssl_ctx\fP will point to a newly initialized object
  49. each time, but note the pointer may be the same as from a prior call.
  50. To use this properly, a non-trivial amount of knowledge of your SSL library is
  51. necessary. For example, you can use this function to call library-specific
  52. callbacks to add additional validation code for certificates, and even to
  53. change the actual URI of an HTTPS request.
  54. WARNING: The \fICURLOPT_SSL_CTX_FUNCTION(3)\fP callback allows the application
  55. to reach in and modify SSL details in the connection without libcurl itself
  56. knowing anything about it, which then subsequently can lead to libcurl
  57. unknowingly reusing SSL connections with different properties. To remedy this
  58. you may set \fICURLOPT_FORBID_REUSE(3)\fP from the callback function.
  59. .SH DEFAULT
  60. NULL
  61. .SH PROTOCOLS
  62. All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
  63. .SH EXAMPLE
  64. See cacertinmem.c in docs/examples directory for usage example.
  65. https://curl.haxx.se/libcurl/c/cacertinmem.html
  66. .SH AVAILABILITY
  67. Added in 7.11.0 for OpenSSL. Added in 7.42.0 for wolfSSL/CyaSSL. Added in
  68. 7.54.0 for mbedTLS. Other SSL backends not supported.
  69. .SH RETURN VALUE
  70. CURLE_OK if supported; or an error such as:
  71. CURLE_NOT_BUILT_IN - Not supported by the SSL backend
  72. CURLE_UNKNOWN_OPTION
  73. .SH "SEE ALSO"
  74. .BR CURLOPT_SSL_CTX_DATA "(3), " CURLOPT_SSL_VERIFYPEER "(3), "