aboutsummaryrefslogtreecommitdiff
path: root/lib/ssluse.c
diff options
context:
space:
mode:
authorGisle Vanem <gvanem@broadpark.no>2004-12-13 16:43:00 +0000
committerGisle Vanem <gvanem@broadpark.no>2004-12-13 16:43:00 +0000
commitbdb0620529ecb58b879dcf7de67885f211812aee (patch)
tree7f704a0a0bd5b15af64dbca14ca724a9b84c7957 /lib/ssluse.c
parentbe9ea07e879b8fc747d562300bac811593d6ede6 (diff)
Added handling of CURLINFO_SSL_ENGINES;
Added Curl_SSL_engines_list(), cleanup SSL in url.c (no HAVE_OPENSSL_x etc.).
Diffstat (limited to 'lib/ssluse.c')
-rw-r--r--lib/ssluse.c80
1 files changed, 78 insertions, 2 deletions
diff --git a/lib/ssluse.c b/lib/ssluse.c
index 8b248628b..a10f2f5fd 100644
--- a/lib/ssluse.c
+++ b/lib/ssluse.c
@@ -482,6 +482,77 @@ void Curl_SSL_Close(struct connectdata *conn)
}
#endif
+
+/* Selects an OpenSSL crypto engine
+ */
+CURLcode Curl_SSL_set_engine(struct SessionHandle *data, const char *engine)
+{
+#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
+ ENGINE *e = ENGINE_by_id(engine);
+
+ if (!e) {
+ failf(data, "SSL Engine '%s' not found", engine);
+ return (CURLE_SSL_ENGINE_NOTFOUND);
+ }
+
+ if (data->engine) {
+ ENGINE_finish(data->engine);
+ ENGINE_free(data->engine);
+ }
+ data->engine = NULL;
+ if (!ENGINE_init(e)) {
+ ENGINE_free(e);
+ failf(data, "Failed to initialise SSL Engine '%s'", engine);
+ return (CURLE_SSL_ENGINE_INITFAILED);
+ }
+ data->engine = e;
+ return (CURLE_OK);
+#else
+ failf(data, "SSL Engine not supported");
+ return (CURLE_SSL_ENGINE_NOTFOUND);
+#endif
+}
+
+/* Sets above engine as default for all SSL operations
+ */
+CURLcode Curl_SSL_set_engine_default(struct SessionHandle *data)
+{
+#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
+ if (data->engine) {
+ if (ENGINE_set_default(data->engine, ENGINE_METHOD_ALL) > 0) {
+ infof(data,"set default crypto engine %s\n", data->engine);
+ }
+ else {
+ failf(data, "set default crypto engine %s failed", data->engine);
+ return CURLE_SSL_ENGINE_SETFAILED;
+ }
+ }
+#else
+ (void) data;
+#endif
+ return (CURLE_OK);
+}
+
+/* Build the list of OpenSSL crypto engine names. Add to
+ * linked list at data->engine_list.
+ */
+CURLcode Curl_SSL_engines_list(struct SessionHandle *data)
+{
+#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
+ ENGINE *e;
+
+ /* Free previous list */
+ if (data->engine_list)
+ curl_slist_free_all(data->engine_list);
+
+ data->engine_list = NULL;
+ for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
+ data->engine_list = curl_slist_append(data->engine_list, ENGINE_get_id(e));
+#endif
+ return (CURLE_OK);
+}
+
+
#ifdef USE_SSLEAY
/*
@@ -620,11 +691,15 @@ int Curl_SSL_Close_All(struct SessionHandle *data)
free(data->state.session);
}
#ifdef HAVE_OPENSSL_ENGINE_H
- if(data->engine)
- {
+ if(data->engine) {
+ ENGINE_finish(data->engine);
ENGINE_free(data->engine);
data->engine = NULL;
}
+ if (data->engine_list)
+ curl_slist_free_all(data->engine_list);
+ data->engine_list = NULL;
+
#endif
return 0;
}
@@ -1483,3 +1558,4 @@ Curl_SSLConnect(struct connectdata *conn,
#endif
return retcode;
}
+