1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 15:48:49 -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:
Gisle Vanem 2004-12-14 14:20:21 +00:00
parent 37c7a695a2
commit 7d3f5d7ac1
4 changed files with 30 additions and 28 deletions

View File

@ -182,8 +182,7 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
*param_longp = data->info.numconnects;
break;
case CURLINFO_SSL_ENGINES:
Curl_SSL_engines_list(data);
*param_slistp = data->state.engine_list;
*param_slistp = Curl_SSL_engines_list(data);
break;
default:
return CURLE_BAD_FUNCTION_ARGUMENT;

View File

@ -412,6 +412,22 @@ int cert_verify_callback(int ok, X509_STORE_CTX *ctx)
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? */
static int init_ssl=0;
@ -480,6 +496,7 @@ void Curl_SSL_Close(struct connectdata *conn)
{
(void)conn;
}
#endif
@ -501,8 +518,11 @@ CURLcode Curl_SSL_set_engine(struct SessionHandle *data, const char *engine)
}
data->state.engine = NULL;
if (!ENGINE_init(e)) {
char buf[256];
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);
}
data->state.engine = e;
@ -533,23 +553,19 @@ CURLcode Curl_SSL_set_engine_default(struct SessionHandle *data)
return (CURLE_OK);
}
/* Build the list of OpenSSL crypto engine names. Add to
* linked list at data->state.engine_list.
/* Return list of OpenSSL crypto engine names.
*/
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)
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))
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
return (CURLE_OK);
(void) data;
return (list);
}
@ -696,10 +712,6 @@ int Curl_SSL_Close_All(struct SessionHandle *data)
ENGINE_free(data->state.engine);
data->state.engine = NULL;
}
if (data->state.engine_list)
curl_slist_free_all(data->state.engine_list);
data->state.engine_list = NULL;
#endif
return 0;
}
@ -1432,14 +1444,7 @@ Curl_SSLConnect(struct connectdata *conn,
}
/* Could be a CERT problem */
#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(errdetail, error_buffer, sizeof(error_buffer));
#else
ERR_error_string(errdetail, error_buffer);
#endif
SSL_strerror(errdetail, error_buffer, sizeof(error_buffer));
failf(data, "%s%s", cert_problem ? cert_problem : "", error_buffer);
return rc;
}

View File

@ -43,6 +43,6 @@ CURLcode Curl_SSL_set_engine(struct SessionHandle *data, const char *engine);
CURLcode Curl_SSL_set_engine_default(struct SessionHandle *data);
/* Build list of OpenSSL engines */
CURLcode Curl_SSL_engines_list(struct SessionHandle *data);
struct curl_slist *Curl_SSL_engines_list(struct SessionHandle *data);
#endif

View File

@ -781,8 +781,6 @@ struct UrlState {
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
ENGINE *engine;
#endif /* USE_SSLEAY */
struct curl_slist *engine_list; /* list of names from ENGINE_get_id() */
};