Skip to content

Commit

Permalink
libcurl: add new API function curl_global_sslget
Browse files Browse the repository at this point in the history
curl_global_sslget retrieves the selected SSL backend id/name.

work in progress.

Ref: #2063
  • Loading branch information
jay committed Nov 9, 2017
1 parent 19e66e5 commit 7026d60
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/libcurl/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ man_MANS = curl_easy_cleanup.3 curl_easy_getinfo.3 curl_easy_init.3 \
curl_mime_init.3 curl_mime_free.3 curl_mime_addpart.3 curl_mime_name.3 \
curl_mime_data.3 curl_mime_data_cb.3 curl_mime_filedata.3 \
curl_mime_filename.3 curl_mime_subparts.3 \
curl_mime_type.3 curl_mime_headers.3 curl_mime_encoder.3
curl_mime_type.3 curl_mime_headers.3 curl_mime_encoder.3 \
curl_global_sslget.3
73 changes: 73 additions & 0 deletions docs/libcurl/curl_global_sslget.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
.\" **************************************************************************
.\" * _ _ ____ _
.\" * Project ___| | | | _ \| |
.\" * / __| | | | |_) | |
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2017, 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.
.\" *
.\" * 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
.\" * furnished to do so, under the terms of the COPYING file.
.\" *
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
.\" * KIND, either express or implied.
.\" *
.\" **************************************************************************
.TH curl_global_sslget 3 "November 8 2017" "libcurl 7.57.1" "libcurl Manual"
.SH NAME
curl_global_sslget - Get the SSL backend selected to be used by libcurl
.SH SYNOPSIS
.B #include <curl/curl.h>
.nf

typedef struct {
curl_sslbackend id;
const char *name;
} curl_ssl_backend;

typedef enum {
CURLSSLBACKEND_NONE = 0,
CURLSSLBACKEND_OPENSSL = 1,
CURLSSLBACKEND_GNUTLS = 2,
CURLSSLBACKEND_NSS = 3,
CURLSSLBACKEND_GSKIT = 5,
CURLSSLBACKEND_POLARSSL = 6,
CURLSSLBACKEND_WOLFSSL = 7,
CURLSSLBACKEND_SCHANNEL = 8,
CURLSSLBACKEND_DARWINSSL = 9,
CURLSSLBACKEND_AXTLS = 10,
CURLSSLBACKEND_MBEDTLS = 11
} curl_sslbackend;

.B "const curl_ssl_backend *curl_global_sslget();"
.fi
.SH DESCRIPTION
This function gets the SSL backend selected to be used by libcurl. This
function is not thread safe if it is called before \fIcurl_global_init(3)\fP.

If libcurl was built without SSL support then \fIid\fP is CURLSSLBACKEND_NONE.

If libcurl was built with support for multiple SSL backends but a backend has
not yet been selected by \fIcurl_global_sslset(3)\fP then \fIid\fP is
CURLSSLBACKEND_NONE.

If the curl_ssl_backend returned by this function has an \fIid\fP other than
CURLSSLBACKEND_NONE then it will not change. That is because libcurl selects
the SSL library to use only once.
.SH AVAILABILITY
This function was added in libcurl 7.57.1. Before this version, only
\fICURLINFO_TLS_SSL_PTR(3)\fP could be used to obtain the SSL backend id.
.SH RETURN VALUE
This function will always return a valid pointer to curl_ssl_backend that
should not be freed.
.SH "SEE ALSO"
.BR curl_global_init "(3), "
.BR curl_global_sslset "(3), "
.BR CURLINFO_TLS_SSL_PTR "(3), "
.BR libcurl "(3) "
1 change: 1 addition & 0 deletions docs/libcurl/curl_global_sslset.3
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@ If this libcurl was built completely without SSL support, with no backends at
all, this function returns \fICURLSSLSET_NO_BACKENDS\fP.
.SH "SEE ALSO"
.BR curl_global_init "(3), "
.BR curl_global_sslget "(3), "
.BR libcurl "(3) "
4 changes: 2 additions & 2 deletions docs/libcurl/curl_version_info.3
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,5 @@ entry.
.SH RETURN VALUE
A pointer to a curl_version_info_data struct.
.SH "SEE ALSO"
\fIcurl_version(3)\fP

.BR curl_version "(3), "
.BR curl_global_sslget "(3) "
4 changes: 3 additions & 1 deletion docs/libcurl/libcurl.3
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ details.

If libcurl was compiled with support for multiple SSL backends, the function
\fIcurl_global_sslset(3)\fP can be called before \fIcurl_global_init(3)\fP
to select the active SSL backend.
to select the active SSL backend. \fIcurl_global_sslget(3)\fP can be used to
retrieve the selected SSL backend even if multiple SSL backends are not
supported.

To transfer files, you create an "easy handle" using \fIcurl_easy_init(3)\fP
for a single individual transfer (in either direction). You then set your
Expand Down
3 changes: 3 additions & 0 deletions include/curl/curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,9 @@ typedef enum {
CURL_EXTERN CURLsslset curl_global_sslset(curl_sslbackend id, const char *name,
const curl_ssl_backend ***avail);

/* Get the selected SSL backend. */
CURL_EXTERN const curl_ssl_backend *curl_global_sslget(void);

/*
* NAME curl_slist_append()
*
Expand Down
11 changes: 11 additions & 0 deletions lib/vtls/vtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,11 @@ CURLsslset curl_global_sslset(curl_sslbackend id, const char *name,
return CURLSSLSET_UNKNOWN_BACKEND;
}

const curl_ssl_backend *curl_global_sslget(void)
{
return &Curl_ssl->info;
}

#else /* USE_SSL */
CURLsslset curl_global_sslset(curl_sslbackend id, const char *name,
const curl_ssl_backend ***avail)
Expand All @@ -1323,4 +1328,10 @@ CURLsslset curl_global_sslset(curl_sslbackend id, const char *name,
return CURLSSLSET_NO_BACKENDS;
}

const curl_ssl_backend *curl_global_sslget(void)
{
static curl_ssl_backend b = { CURLSSLBACKEND_NONE, "none" };
return &b;
}

#endif /* !USE_SSL */

0 comments on commit 7026d60

Please sign in to comment.