summaryrefslogtreecommitdiff
path: root/docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.3
diff options
context:
space:
mode:
Diffstat (limited to 'docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.3')
-rw-r--r--docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.341
1 files changed, 22 insertions, 19 deletions
diff --git a/docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.3 b/docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.3
index 167fe327a..2d984d238 100644
--- a/docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.3
+++ b/docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.3
@@ -5,11 +5,11 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
-.\" * are also available at https://curl.haxx.se/docs/copyright.html.
+.\" * are also available at https://curl.se/docs/copyright.html.
.\" *
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
.\" * copies of the Software, and permit persons to whom the Software is
@@ -20,17 +20,19 @@
.\" *
.\" **************************************************************************
.\"
-.TH CURLOPT_SSL_CTX_DATA 3 "June 02, 2019" "libcurl 7.73.0" "curl_easy_setopt options"
+.TH CURLOPT_SSL_CTX_DATA 3 "November 26, 2021" "libcurl 7.81.0" "curl_easy_setopt options"
.SH NAME
-CURLOPT_SSL_CTX_DATA \- custom pointer passed to ssl_ctx callback
+CURLOPT_SSL_CTX_DATA \- pointer passed to ssl_ctx callback
.SH SYNOPSIS
+.nf
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_CTX_DATA, void *pointer);
+.fi
.SH DESCRIPTION
Data \fIpointer\fP to pass to the ssl context callback set by the option
-\fICURLOPT_SSL_CTX_FUNCTION(3)\fP, this is the pointer you'll get as third
+\fICURLOPT_SSL_CTX_FUNCTION(3)\fP, this is the pointer you will get as third
parameter.
.SH DEFAULT
NULL
@@ -47,11 +49,11 @@ All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
{
X509_STORE *store;
- X509 *cert=NULL;
+ X509 *cert = NULL;
BIO *bio;
- char *mypem = (char *)parm;
+ char *mypem = parm;
/* get a BIO */
- bio=BIO_new_mem_buf(mypem, -1);
+ bio = BIO_new_mem_buf(mypem, -1);
/* use it to read the PEM formatted certificate from memory into an
* X509 structure that SSL can use
*/
@@ -60,10 +62,10 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
printf("PEM_read_bio_X509 failed...\\n");
/* get a pointer to the X509 certificate store (which may be empty) */
- store=SSL_CTX_get_cert_store((SSL_CTX *)sslctx);
+ store = SSL_CTX_get_cert_store((SSL_CTX *)sslctx);
/* add our certificate to this store */
- if(X509_STORE_add_cert(store, cert)==0)
+ if(X509_STORE_add_cert(store, cert) == 0)
printf("error adding certificate\\n");
/* decrease reference counts */
@@ -89,20 +91,21 @@ int main(void)
"omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD\\n"
"-----END CERTIFICATE-----\\n";
- rv=curl_global_init(CURL_GLOBAL_ALL);
- ch=curl_easy_init();
- rv=curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, "PEM");
- rv=curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L);
- rv=curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/");
+ curl_global_init(CURL_GLOBAL_ALL);
+ ch = curl_easy_init();
+
+ curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, "PEM");
+ curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L);
+ curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/");
/* Retrieve page using cacerts' certificate -> will succeed
* load the certificate by installing a function doing the necessary
* "modifications" to the SSL CONTEXT just before link init
*/
- rv=curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function);
- rv=curl_easy_setopt(ch, CURLOPT_SSL_CTX_DATA, mypem);
- rv=curl_easy_perform(ch);
- if(rv==CURLE_OK)
+ curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function);
+ curl_easy_setopt(ch, CURLOPT_SSL_CTX_DATA, mypem);
+ rv = curl_easy_perform(ch);
+ if(!rv)
printf("*** transfer succeeded ***\\n");
else
printf("*** transfer failed ***\\n");