1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

vtls: refactor out essential information about the SSL backends

There is information about the compiled-in SSL backends that is really
no concern of any code other than the SSL backend itself, such as which
function (if any) implements SHA-256 summing.

And there is information that is really interesting to the user, such as
the name, or the curl_sslbackend value.

Let's factor out the latter into a publicly visible struct. This
information will be used in the upcoming API to set the SSL backend
globally.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2017-07-15 13:49:30 +02:00 committed by Daniel Stenberg
parent b0989cd3ab
commit b59288f881
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
13 changed files with 23 additions and 26 deletions

View File

@ -2540,6 +2540,11 @@ CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask);
#define CURLPAUSE_ALL (CURLPAUSE_RECV|CURLPAUSE_SEND)
#define CURLPAUSE_CONT (CURLPAUSE_RECV_CONT|CURLPAUSE_SEND_CONT)
typedef struct {
curl_sslbackend id;
const char *name;
} curl_ssl_backend;
#ifdef __cplusplus
}
#endif

View File

@ -702,8 +702,7 @@ static void *Curl_axtls_get_internals(struct ssl_connect_data *connssl,
}
const struct Curl_ssl Curl_ssl_axtls = {
"axtls", /* name */
CURLSSLBACKEND_AXTLS,
{ CURLSSLBACKEND_AXTLS, "axtls" }, /* info */
0, /* have_ca_path */
0, /* have_certinfo */

View File

@ -978,8 +978,7 @@ static void *Curl_cyassl_get_internals(struct ssl_connect_data *connssl,
}
const struct Curl_ssl Curl_ssl_cyassl = {
"cyassl", /* name */
CURLSSLBACKEND_CYASSL,
{ CURLSSLBACKEND_CYASSL, "cyassl" }, /* info */
0, /* have_ca_path */
0, /* have_certinfo */

View File

@ -2890,8 +2890,7 @@ static void *Curl_darwinssl_get_internals(struct ssl_connect_data *connssl,
}
const struct Curl_ssl Curl_ssl_darwinssl = {
"darwinssl", /* name */
CURLSSLBACKEND_DARWINSSL,
{ CURLSSLBACKEND_DARWINSSL, "darwinssl" }, /* info */
0, /* have_ca_path */
0, /* have_certinfo */

View File

@ -1353,8 +1353,7 @@ static void *Curl_gskit_get_internals(struct ssl_connect_data *connssl,
}
const struct Curl_ssl Curl_ssl_gskit = {
"gskit", /* name */
CURLSSLBACKEND_GSKIT,
{ CURLSSLBACKEND_GSKIT, "gskit" }, /* info */
0, /* have_ca_path */
1, /* have_certinfo */

View File

@ -1806,8 +1806,7 @@ static void *Curl_gtls_get_internals(struct ssl_connect_data *connssl,
}
const struct Curl_ssl Curl_ssl_gnutls = {
"gnutls", /* name */
CURLSSLBACKEND_GNUTLS,
{ CURLSSLBACKEND_GNUTLS, "gnutls" }, /* info */
1, /* have_ca_path */
1, /* have_certinfo */

View File

@ -1039,8 +1039,7 @@ static void *Curl_mbedtls_get_internals(struct ssl_connect_data *connssl,
}
const struct Curl_ssl Curl_ssl_mbedtls = {
"mbedtls", /* name */
CURLSSLBACKEND_MBEDTLS,
{ CURLSSLBACKEND_MBEDTLS, "mbedtls" }, /* info */
0, /* have_ca_path */
0, /* have_certinfo */

View File

@ -2343,8 +2343,7 @@ static void *Curl_nss_get_internals(struct ssl_connect_data *connssl,
}
const struct Curl_ssl Curl_ssl_nss = {
"nss", /* name */
CURLSSLBACKEND_NSS,
{ CURLSSLBACKEND_NSS, "nss" }, /* info */
1, /* have_ca_path */
1, /* have_certinfo */

View File

@ -3416,8 +3416,7 @@ static void *Curl_ossl_get_internals(struct ssl_connect_data *connssl,
}
const struct Curl_ssl Curl_ssl_openssl = {
"openssl", /* name */
CURLSSLBACKEND_OPENSSL,
{ CURLSSLBACKEND_OPENSSL, "openssl" }, /* info */
1, /* have_ca_path */
1, /* have_certinfo */

View File

@ -901,8 +901,7 @@ static void *Curl_polarssl_get_internals(struct ssl_connect_data *connssl,
}
const struct Curl_ssl Curl_ssl_polarssl = {
"polarssl", /* name */
CURLSSLBACKEND_POLARSSL,
{ CURLSSLBACKEND_POLARSSL, "polarssl" }, /* info */
1, /* have_ca_path */
0, /* have_certinfo */

View File

@ -1816,8 +1816,7 @@ static void *Curl_schannel_get_internals(struct ssl_connect_data *connssl,
}
const struct Curl_ssl Curl_ssl_schannel = {
"schannel", /* name */
CURLSSLBACKEND_SCHANNEL,
{ CURLSSLBACKEND_SCHANNEL, "schannel" }, /* info */
0, /* have_ca_path */
1, /* have_certinfo */

View File

@ -138,7 +138,7 @@ int Curl_ssl_backend(void)
{
#ifdef USE_SSL
multissl_init();
return Curl_ssl->id;
return Curl_ssl->info.id;
#else
return (int)CURLSSLBACKEND_NONE;
#endif
@ -1099,8 +1099,7 @@ static void Curl_multissl_close(struct connectdata *conn, int sockindex)
}
static const struct Curl_ssl Curl_ssl_multi = {
"multi", /* name */
CURLSSLBACKEND_NONE,
{ CURLSSLBACKEND_NONE, "multi" }, /* info */
0, /* have_ca_path */
0, /* have_certinfo */
@ -1182,7 +1181,7 @@ static int multissl_init(void)
env = getenv("CURL_SSL_BACKEND");
if(env)
for(i = 0; available_backends[i]; i++)
if(!strcmp(env, available_backends[i]->name)) {
if(!strcmp(env, available_backends[i]->info.name)) {
Curl_ssl = available_backends[i];
return 0;
}

View File

@ -27,8 +27,11 @@ struct connectdata;
struct ssl_connect_data;
struct Curl_ssl {
const char *name;
int id; /* one of the CURLSSLBACKEND_* constants */
/*
* This *must* be the first entry to allow returning the list of available
* backends in curl_global_sslset().
*/
curl_ssl_backend info;
unsigned have_ca_path:1; /* supports CAPATH */
unsigned have_certinfo:1; /* supports CURLOPT_CERTINFO */