Skip to content

Commit

Permalink
Merge 3eda95f into e9d9d1a
Browse files Browse the repository at this point in the history
  • Loading branch information
bagder committed May 4, 2018
2 parents e9d9d1a + 3eda95f commit 0ce51a6
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 89 deletions.
14 changes: 7 additions & 7 deletions lib/setopt.c
Expand Up @@ -1748,7 +1748,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
* Set a SSL_CTX callback
*/
#ifdef USE_SSL
if(Curl_ssl->have_ssl_ctx)
if(Curl_ssl->supports & SSLSUPP_SSL_CTX)
data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback);
else
#endif
Expand All @@ -1759,7 +1759,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
* Set a SSL_CTX callback parameter pointer
*/
#ifdef USE_SSL
if(Curl_ssl->have_ssl_ctx)
if(Curl_ssl->supports & SSLSUPP_SSL_CTX)
data->set.ssl.fsslctxp = va_arg(param, void *);
else
#endif
Expand All @@ -1778,7 +1778,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
break;
case CURLOPT_CERTINFO:
#ifdef USE_SSL
if(Curl_ssl->have_certinfo)
if(Curl_ssl->supports & SSLSUPP_CERTINFO)
data->set.ssl.certinfo = (0 != va_arg(param, long)) ? TRUE : FALSE;
else
#endif
Expand All @@ -1790,7 +1790,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
* Specify file name of the public key in DER format.
*/
#ifdef USE_SSL
if(Curl_ssl->have_pinnedpubkey)
if(Curl_ssl->supports & SSLSUPP_PINNEDPUBKEY)
result = Curl_setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG],
va_arg(param, char *));
else
Expand All @@ -1803,7 +1803,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
* Specify file name of the public key in DER format.
*/
#ifdef USE_SSL
if(Curl_ssl->have_pinnedpubkey)
if(Curl_ssl->supports & SSLSUPP_PINNEDPUBKEY)
result = Curl_setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY],
va_arg(param, char *));
else
Expand Down Expand Up @@ -1831,7 +1831,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
* certificates which have been prepared using openssl c_rehash utility.
*/
#ifdef USE_SSL
if(Curl_ssl->have_ca_path)
if(Curl_ssl->supports & SSLSUPP_CA_PATH)
/* This does not work on windows. */
result = Curl_setstropt(&data->set.str[STRING_SSL_CAPATH_ORIG],
va_arg(param, char *));
Expand All @@ -1845,7 +1845,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
* CA certificates which have been prepared using openssl c_rehash utility.
*/
#ifdef USE_SSL
if(Curl_ssl->have_ca_path)
if(Curl_ssl->supports & SSLSUPP_CA_PATH)
/* This does not work on windows. */
result = Curl_setstropt(&data->set.str[STRING_SSL_CAPATH_PROXY],
va_arg(param, char *));
Expand Down
2 changes: 1 addition & 1 deletion lib/url.c
Expand Up @@ -2740,7 +2740,7 @@ static CURLcode parse_proxy(struct Curl_easy *data,
proxyptr = proxy; /* No xxx:// head: It's a HTTP proxy */

#ifdef USE_SSL
if(!Curl_ssl->support_https_proxy)
if(!(Curl_ssl->supports & SSLSUPP_HTTPS_PROXY))
#endif
if(proxytype == CURLPROXY_HTTPS) {
failf(data, "Unsupported proxy \'%s\', libcurl is built without the "
Expand Down
4 changes: 2 additions & 2 deletions lib/version.c
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2018, 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
Expand Down Expand Up @@ -399,7 +399,7 @@ curl_version_info_data *curl_version_info(CURLversion stamp)
#ifdef USE_SSL
Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
version_info.ssl_version = ssl_buffer;
if(Curl_ssl->support_https_proxy)
if(Curl_ssl->supports & SSLSUPP_HTTPS_PROXY)
version_info.features |= CURL_VERSION_HTTPS_PROXY;
else
version_info.features &= ~CURL_VERSION_HTTPS_PROXY;
Expand Down
10 changes: 2 additions & 8 deletions lib/vtls/axtls.c
Expand Up @@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2010, DirecTV, Contact: Eric Hu, <ehu@directv.com>.
* Copyright (C) 2010 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2010 - 2018, 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
Expand Down Expand Up @@ -703,13 +703,7 @@ static void *Curl_axtls_get_internals(struct ssl_connect_data *connssl,

const struct Curl_ssl Curl_ssl_axtls = {
{ CURLSSLBACKEND_AXTLS, "axtls" }, /* info */

0, /* have_ca_path */
0, /* have_certinfo */
0, /* have_pinnedpubkey */
0, /* have_ssl_ctx */
0, /* support_https_proxy */

0, /* no fancy stuff */
sizeof(struct ssl_backend_data),

/*
Expand Down
9 changes: 2 additions & 7 deletions lib/vtls/cyassl.c
Expand Up @@ -994,15 +994,10 @@ static void *Curl_cyassl_get_internals(struct ssl_connect_data *connssl,
const struct Curl_ssl Curl_ssl_cyassl = {
{ CURLSSLBACKEND_WOLFSSL, "WolfSSL" }, /* info */

0, /* have_ca_path */
0, /* have_certinfo */
#ifdef KEEP_PEER_CERT
1, /* have_pinnedpubkey */
#else
0, /* have_pinnedpubkey */
SSLSUPP_PINNEDPUBKEY |
#endif
1, /* have_ssl_ctx */
0, /* support_https_proxy */
SSLSUPP_SSL_CTX

sizeof(struct ssl_backend_data),

Expand Down
10 changes: 3 additions & 7 deletions lib/vtls/darwinssl.c
Expand Up @@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012 - 2017, Nick Zitzmann, <nickzman@gmail.com>.
* Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2012 - 2018, 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
Expand Down Expand Up @@ -3029,15 +3029,11 @@ static void *Curl_darwinssl_get_internals(struct ssl_connect_data *connssl,
const struct Curl_ssl Curl_ssl_darwinssl = {
{ CURLSSLBACKEND_DARWINSSL, "darwinssl" }, /* info */

0, /* have_ca_path */
0, /* have_certinfo */
#ifdef DARWIN_SSL_PINNEDPUBKEY
1, /* have_pinnedpubkey */
SSLSUPP_PINNEDPUBKEY,
#else
0, /* have_pinnedpubkey */
0,
#endif /* DARWIN_SSL_PINNEDPUBKEY */
0, /* have_ssl_ctx */
0, /* support_https_proxy */

sizeof(struct ssl_backend_data),

Expand Down
10 changes: 3 additions & 7 deletions lib/vtls/gskit.c
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2018, 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
Expand Down Expand Up @@ -1353,12 +1353,8 @@ static void *Curl_gskit_get_internals(struct ssl_connect_data *connssl,
const struct Curl_ssl Curl_ssl_gskit = {
{ CURLSSLBACKEND_GSKIT, "gskit" }, /* info */

0, /* have_ca_path */
1, /* have_certinfo */
1, /* have_pinnedpubkey */
0, /* have_ssl_ctx */
/* TODO: convert to 1 and fix test #1014 (if need) */
0, /* support_https_proxy */
SSLSUPP_CERTINFO |
SSLSUPP_PINNEDPUBKEY

sizeof(struct ssl_backend_data),

Expand Down
9 changes: 4 additions & 5 deletions lib/vtls/gtls.c
Expand Up @@ -1802,11 +1802,10 @@ static void *Curl_gtls_get_internals(struct ssl_connect_data *connssl,
const struct Curl_ssl Curl_ssl_gnutls = {
{ CURLSSLBACKEND_GNUTLS, "gnutls" }, /* info */

1, /* have_ca_path */
1, /* have_certinfo */
1, /* have_pinnedpubkey */
0, /* have_ssl_ctx */
1, /* support_https_proxy */
SSLSUPP_CA_PATH |
SSLSUPP_CERTINFO |
SSLSUPP_PINNEDPUBKEY |
SSLSUPP_HTTPS_PROXY,

sizeof(struct ssl_backend_data),

Expand Down
10 changes: 4 additions & 6 deletions lib/vtls/mbedtls.c
Expand Up @@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2010 - 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com>
* Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2012 - 2018, 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
Expand Down Expand Up @@ -1049,11 +1049,9 @@ static void *Curl_mbedtls_get_internals(struct ssl_connect_data *connssl,
const struct Curl_ssl Curl_ssl_mbedtls = {
{ CURLSSLBACKEND_MBEDTLS, "mbedtls" }, /* info */

1, /* have_ca_path */
0, /* have_certinfo */
1, /* have_pinnedpubkey */
1, /* have_ssl_ctx */
0, /* support_https_proxy */
SSLSUPP_CA_PATH |
SSLSUPP_PINNEDPUBKEY |
SSLSUPP_SSL_CTX,

sizeof(struct ssl_backend_data),

Expand Down
11 changes: 5 additions & 6 deletions lib/vtls/nss.c
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2018, 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
Expand Down Expand Up @@ -2357,11 +2357,10 @@ static void *Curl_nss_get_internals(struct ssl_connect_data *connssl,
const struct Curl_ssl Curl_ssl_nss = {
{ CURLSSLBACKEND_NSS, "nss" }, /* info */

1, /* have_ca_path */
1, /* have_certinfo */
1, /* have_pinnedpubkey */
0, /* have_ssl_ctx */
1, /* support_https_proxy */
SSLSUPP_CA_PATH |
SSLSUPP_CERTINFO |
SSLSUPP_PINNEDPUBKEY |
SSLSUPP_HTTPS_PROXY,

sizeof(struct ssl_backend_data),

Expand Down
10 changes: 5 additions & 5 deletions lib/vtls/openssl.c
Expand Up @@ -3724,11 +3724,11 @@ static void *Curl_ossl_get_internals(struct ssl_connect_data *connssl,
const struct Curl_ssl Curl_ssl_openssl = {
{ CURLSSLBACKEND_OPENSSL, "openssl" }, /* info */

1, /* have_ca_path */
1, /* have_certinfo */
1, /* have_pinnedpubkey */
1, /* have_ssl_ctx */
1, /* support_https_proxy */
SSLSUPP_CA_PATH |
SSLSUPP_CERTINFO |
SSLSUPP_PINNEDPUBKEY |
SSLSUPP_SSL_CTX |
SSLSUPP_HTTPS_PROXY,

sizeof(struct ssl_backend_data),

Expand Down
9 changes: 3 additions & 6 deletions lib/vtls/polarssl.c
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2012 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2010 - 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com>
*
* This software is licensed as described in the file COPYING, which
Expand Down Expand Up @@ -900,11 +900,8 @@ static void *Curl_polarssl_get_internals(struct ssl_connect_data *connssl,
const struct Curl_ssl Curl_ssl_polarssl = {
{ CURLSSLBACKEND_POLARSSL, "polarssl" }, /* info */

1, /* have_ca_path */
0, /* have_certinfo */
1, /* have_pinnedpubkey */
0, /* have_ssl_ctx */
0, /* support_https_proxy */
SSLSUPP_CA_PATH |
SSLSUPP_PINNEDPUBKEY,

sizeof(struct ssl_backend_data),

Expand Down
7 changes: 2 additions & 5 deletions lib/vtls/schannel.c
Expand Up @@ -1923,11 +1923,8 @@ static void *Curl_schannel_get_internals(struct ssl_connect_data *connssl,
const struct Curl_ssl Curl_ssl_schannel = {
{ CURLSSLBACKEND_SCHANNEL, "schannel" }, /* info */

0, /* have_ca_path */
1, /* have_certinfo */
1, /* have_pinnedpubkey */
0, /* have_ssl_ctx */
0, /* support_https_proxy */
SSLSUPP_CERTINFO |
SSLSUPP_PINNEDPUBKEY

sizeof(struct ssl_backend_data),

Expand Down
12 changes: 3 additions & 9 deletions lib/vtls/vtls.c
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2018, 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
Expand Down Expand Up @@ -211,7 +211,7 @@ ssl_connect_init_proxy(struct connectdata *conn, int sockindex)
!conn->proxy_ssl[sockindex].use) {
struct ssl_backend_data *pbdata;

if(!Curl_ssl->support_https_proxy)
if(!(Curl_ssl->supports & SSLSUPP_HTTPS_PROXY))
return CURLE_NOT_BUILT_IN;

/* The pointers to the ssl backend data, which is opaque here, are swapped
Expand Down Expand Up @@ -1131,13 +1131,7 @@ static void Curl_multissl_close(struct connectdata *conn, int sockindex)

static const struct Curl_ssl Curl_ssl_multi = {
{ CURLSSLBACKEND_NONE, "multi" }, /* info */

0, /* have_ca_path */
0, /* have_certinfo */
0, /* have_pinnedpubkey */
0, /* have_ssl_ctx */
0, /* support_https_proxy */

0, /* supports nothing */
(size_t)-1, /* something insanely large to be on the safe side */

Curl_multissl_init, /* init */
Expand Down
15 changes: 7 additions & 8 deletions lib/vtls/vtls.h
Expand Up @@ -26,20 +26,19 @@
struct connectdata;
struct ssl_connect_data;

#define SSLSUPP_CA_PATH (1<<0) /* supports CAPATH */
#define SSLSUPP_CERTINFO (1<<1) /* supports CURLOPT_CERTINFO */
#define SSLSUPP_PINNEDPUBKEY (1<<2) /* supports CURLOPT_PINNEDPUBLICKEY */
#define SSLSUPP_SSL_CTX (1<<3) /* supports CURLOPT_SSL_CTX */
#define SSLSUPP_HTTPS_PROXY (1<<4) /* supports access via HTTPS proxies */

struct Curl_ssl {
/*
* 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 */
unsigned have_pinnedpubkey:1; /* supports CURLOPT_PINNEDPUBLICKEY */
unsigned have_ssl_ctx:1; /* supports CURLOPT_SSL_CTX_* */

unsigned support_https_proxy:1; /* supports access via HTTPS proxies */

unsigned int supports; /* bitfield, see above */
size_t sizeof_ssl_backend_data;

int (*init)(void);
Expand Down

0 comments on commit 0ce51a6

Please sign in to comment.