mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
urldata.h: Removed engine_list.
ssluse.*: Added SSL_strerror(). Curl_SSL_engines_list() now returns a slist which must be freed by caller.
This commit is contained in:
parent
37c7a695a2
commit
7d3f5d7ac1
@ -182,8 +182,7 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
|
|||||||
*param_longp = data->info.numconnects;
|
*param_longp = data->info.numconnects;
|
||||||
break;
|
break;
|
||||||
case CURLINFO_SSL_ENGINES:
|
case CURLINFO_SSL_ENGINES:
|
||||||
Curl_SSL_engines_list(data);
|
*param_slistp = Curl_SSL_engines_list(data);
|
||||||
*param_slistp = data->state.engine_list;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
51
lib/ssluse.c
51
lib/ssluse.c
@ -412,6 +412,22 @@ int cert_verify_callback(int ok, X509_STORE_CTX *ctx)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return error string for last OpenSSL error
|
||||||
|
*/
|
||||||
|
static char *SSL_strerror(unsigned long error, char *buf, size_t size)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_ERR_ERROR_STRING_N
|
||||||
|
/* OpenSSL 0.9.6 and later has a function named
|
||||||
|
ERRO_error_string_n() that takes the size of the buffer as a
|
||||||
|
third argument */
|
||||||
|
ERR_error_string_n(error, buf, size);
|
||||||
|
#else
|
||||||
|
(void) size;
|
||||||
|
ERR_error_string(error, buf);
|
||||||
|
#endif
|
||||||
|
return (buf);
|
||||||
|
}
|
||||||
|
|
||||||
/* "global" init done? */
|
/* "global" init done? */
|
||||||
static int init_ssl=0;
|
static int init_ssl=0;
|
||||||
|
|
||||||
@ -480,6 +496,7 @@ void Curl_SSL_Close(struct connectdata *conn)
|
|||||||
{
|
{
|
||||||
(void)conn;
|
(void)conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -501,8 +518,11 @@ CURLcode Curl_SSL_set_engine(struct SessionHandle *data, const char *engine)
|
|||||||
}
|
}
|
||||||
data->state.engine = NULL;
|
data->state.engine = NULL;
|
||||||
if (!ENGINE_init(e)) {
|
if (!ENGINE_init(e)) {
|
||||||
|
char buf[256];
|
||||||
|
|
||||||
ENGINE_free(e);
|
ENGINE_free(e);
|
||||||
failf(data, "Failed to initialise SSL Engine '%s'", engine);
|
failf(data, "Failed to initialise SSL Engine '%s':\n%s",
|
||||||
|
engine, SSL_strerror(ERR_get_error(), buf, sizeof(buf)));
|
||||||
return (CURLE_SSL_ENGINE_INITFAILED);
|
return (CURLE_SSL_ENGINE_INITFAILED);
|
||||||
}
|
}
|
||||||
data->state.engine = e;
|
data->state.engine = e;
|
||||||
@ -533,23 +553,19 @@ CURLcode Curl_SSL_set_engine_default(struct SessionHandle *data)
|
|||||||
return (CURLE_OK);
|
return (CURLE_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build the list of OpenSSL crypto engine names. Add to
|
/* Return list of OpenSSL crypto engine names.
|
||||||
* linked list at data->state.engine_list.
|
|
||||||
*/
|
*/
|
||||||
CURLcode Curl_SSL_engines_list(struct SessionHandle *data)
|
struct curl_slist *Curl_SSL_engines_list(struct SessionHandle *data)
|
||||||
{
|
{
|
||||||
|
struct curl_slist *list = NULL;
|
||||||
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
|
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
|
||||||
ENGINE *e;
|
ENGINE *e;
|
||||||
|
|
||||||
/* Free previous list */
|
|
||||||
if (data->state.engine_list)
|
|
||||||
curl_slist_free_all(data->state.engine_list);
|
|
||||||
|
|
||||||
data->state.engine_list = NULL;
|
|
||||||
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
|
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
|
||||||
data->state.engine_list = curl_slist_append(data->state.engine_list, ENGINE_get_id(e));
|
list = curl_slist_append(list, ENGINE_get_id(e));
|
||||||
#endif
|
#endif
|
||||||
return (CURLE_OK);
|
(void) data;
|
||||||
|
return (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -696,10 +712,6 @@ int Curl_SSL_Close_All(struct SessionHandle *data)
|
|||||||
ENGINE_free(data->state.engine);
|
ENGINE_free(data->state.engine);
|
||||||
data->state.engine = NULL;
|
data->state.engine = NULL;
|
||||||
}
|
}
|
||||||
if (data->state.engine_list)
|
|
||||||
curl_slist_free_all(data->state.engine_list);
|
|
||||||
data->state.engine_list = NULL;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1432,14 +1444,7 @@ Curl_SSLConnect(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
/* Could be a CERT problem */
|
/* Could be a CERT problem */
|
||||||
|
|
||||||
#ifdef HAVE_ERR_ERROR_STRING_N
|
SSL_strerror(errdetail, error_buffer, sizeof(error_buffer));
|
||||||
/* OpenSSL 0.9.6 and later has a function named
|
|
||||||
ERRO_error_string_n() that takes the size of the buffer as a
|
|
||||||
third argument */
|
|
||||||
ERR_error_string_n(errdetail, error_buffer, sizeof(error_buffer));
|
|
||||||
#else
|
|
||||||
ERR_error_string(errdetail, error_buffer);
|
|
||||||
#endif
|
|
||||||
failf(data, "%s%s", cert_problem ? cert_problem : "", error_buffer);
|
failf(data, "%s%s", cert_problem ? cert_problem : "", error_buffer);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,6 @@ CURLcode Curl_SSL_set_engine(struct SessionHandle *data, const char *engine);
|
|||||||
CURLcode Curl_SSL_set_engine_default(struct SessionHandle *data);
|
CURLcode Curl_SSL_set_engine_default(struct SessionHandle *data);
|
||||||
|
|
||||||
/* Build list of OpenSSL engines */
|
/* Build list of OpenSSL engines */
|
||||||
CURLcode Curl_SSL_engines_list(struct SessionHandle *data);
|
struct curl_slist *Curl_SSL_engines_list(struct SessionHandle *data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -781,8 +781,6 @@ struct UrlState {
|
|||||||
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
|
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
|
||||||
ENGINE *engine;
|
ENGINE *engine;
|
||||||
#endif /* USE_SSLEAY */
|
#endif /* USE_SSLEAY */
|
||||||
struct curl_slist *engine_list; /* list of names from ENGINE_get_id() */
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user