aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGisle Vanem <gvanem@broadpark.no>2004-12-14 14:20:21 +0000
committerGisle Vanem <gvanem@broadpark.no>2004-12-14 14:20:21 +0000
commit7d3f5d7ac101b180aefaf2430e0ee09620883e99 (patch)
tree31ece334add11c0d8dd2cf9520a65dcbf7361b2f /lib
parent37c7a695a204f4c59c99cac7eaf86a66514663bc (diff)
urldata.h: Removed engine_list.
ssluse.*: Added SSL_strerror(). Curl_SSL_engines_list() now returns a slist which must be freed by caller.
Diffstat (limited to 'lib')
-rw-r--r--lib/getinfo.c3
-rw-r--r--lib/ssluse.c51
-rw-r--r--lib/ssluse.h2
-rw-r--r--lib/urldata.h2
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() */
-
};