diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/getinfo.c | 3 | ||||
-rw-r--r-- | lib/ssluse.c | 51 | ||||
-rw-r--r-- | lib/ssluse.h | 2 | ||||
-rw-r--r-- | lib/urldata.h | 2 |
4 files changed, 30 insertions, 28 deletions
diff --git a/lib/getinfo.c b/lib/getinfo.c index 084dddf9e..6ab6f9587 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -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; diff --git a/lib/ssluse.c b/lib/ssluse.c index f1df3b959..f86834370 100644 --- a/lib/ssluse.c +++ b/lib/ssluse.c @@ -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; } diff --git a/lib/ssluse.h b/lib/ssluse.h index ea7a378e5..81c223d20 100644 --- a/lib/ssluse.h +++ b/lib/ssluse.h @@ -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 diff --git a/lib/urldata.h b/lib/urldata.h index 6acc2f7a8..a58a9e47d 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -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() */ - }; |