]> granicus.if.org Git - curl/commitdiff
vtls: refactor out essential information about the SSL backends
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Sat, 15 Jul 2017 11:49:30 +0000 (13:49 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 28 Aug 2017 12:56:58 +0000 (14:56 +0200)
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>
13 files changed:
include/curl/curl.h
lib/vtls/axtls.c
lib/vtls/cyassl.c
lib/vtls/darwinssl.c
lib/vtls/gskit.c
lib/vtls/gtls.c
lib/vtls/mbedtls.c
lib/vtls/nss.c
lib/vtls/openssl.c
lib/vtls/polarssl.c
lib/vtls/schannel.c
lib/vtls/vtls.c
lib/vtls/vtls.h

index 3936d1e43c848dcad1b01b114a09e46761b1c03f..146044398fe7b978399bfb0b967e0f834c40509a 100644 (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
index cfdb1b70fc21a8368704ac492368083bb72c3de8..3531296bb2323e35781e87ded4565e04a6971b45 100644 (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 */
index d679752fbda8ca62dbe7091239a1afd7cf549bad..122cfda578eab9ef5ee15c435015153a11f80d66 100644 (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 */
index b2ca52cb72658f0be9c5496bb1c2838979d7ab66..d6503216a3f1cd6a93fc01fafdc81702381b965b 100644 (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 */
index a1599dd5fa85d16d574fa038666e107048596af9..ba5faeff8e43e6f30b91960228111254d91582b7 100644 (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 */
index 498634b29c01bc0c782a3595d8d94e59e95eea8b..07de85d8f302aea09af79ac38f9d0ae1deb7a47e 100644 (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 */
index d7e16177bd3f490dc9b1368e35578bc0c2aa8d40..8a0f05b62fe7c2001efe4a0e79793bec3bb447e4 100644 (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 */
index 91f6530afab5d730e1b1518340fd38b28ca2be9e..d06b8c8ae2eb7de022a608ec94dbe4c8b48dbc87 100644 (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 */
index 136d8e4752c5b203a684757bf7e3e3be70ea6dd1..394ce2e3d3e12f5f316824a78b580fb7d5d30e7c 100644 (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 */
index 9d4aeacfb7421abbee8a1f4979cfb05d8594dff5..fdfd12ce5f7b135fc6f1eea1362c945e39676902 100644 (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 */
index bd7a85bae529368fd8f47417c69df8a2a99260b7..473bebe211485de0545d9ccb1f1e7094c5800dc6 100644 (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 */
index ed43e1d467badcd943d45a852bdf2ad7ce25b29c..b149d40cffbfd70b09275f5d3d95b108141f9ed7 100644 (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;
       }
index 7d22969523074f8697143e081fcb079e69d95472..3c8e32104bb9c5f6605741d0dd747778d5abe9ef 100644 (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 */