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