Moved the engine stuff from the root-level of the SessionHandle struct to the

UrlState sub-struct. Also made the engine_list exist for non-ssl builds to
make curl build.
This commit is contained in:
Daniel Stenberg 2004-12-14 09:36:22 +00:00
parent 5c14b3be6d
commit 07f107ae20
3 changed files with 30 additions and 29 deletions

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

@ -329,7 +329,7 @@ int cert_stuff(struct connectdata *conn,
#ifdef HAVE_OPENSSL_ENGINE_H #ifdef HAVE_OPENSSL_ENGINE_H
{ /* XXXX still needs some work */ { /* XXXX still needs some work */
EVP_PKEY *priv_key = NULL; EVP_PKEY *priv_key = NULL;
if(conn && conn->data && conn->data->engine) { if(conn && conn->data && conn->data->state.engine) {
#ifdef HAVE_ENGINE_LOAD_FOUR_ARGS #ifdef HAVE_ENGINE_LOAD_FOUR_ARGS
UI_METHOD *ui_method = UI_OpenSSL(); UI_METHOD *ui_method = UI_OpenSSL();
#endif #endif
@ -339,7 +339,7 @@ int cert_stuff(struct connectdata *conn,
} }
/* the typecast below was added to please mingw32 */ /* the typecast below was added to please mingw32 */
priv_key = (EVP_PKEY *) priv_key = (EVP_PKEY *)
ENGINE_load_private_key(conn->data->engine,key_file, ENGINE_load_private_key(conn->data->state.engine,key_file,
#ifdef HAVE_ENGINE_LOAD_FOUR_ARGS #ifdef HAVE_ENGINE_LOAD_FOUR_ARGS
ui_method, ui_method,
#endif #endif
@ -495,17 +495,17 @@ CURLcode Curl_SSL_set_engine(struct SessionHandle *data, const char *engine)
return (CURLE_SSL_ENGINE_NOTFOUND); return (CURLE_SSL_ENGINE_NOTFOUND);
} }
if (data->engine) { if (data->state.engine) {
ENGINE_finish(data->engine); ENGINE_finish(data->state.engine);
ENGINE_free(data->engine); ENGINE_free(data->state.engine);
} }
data->engine = NULL; data->state.engine = NULL;
if (!ENGINE_init(e)) { if (!ENGINE_init(e)) {
ENGINE_free(e); ENGINE_free(e);
failf(data, "Failed to initialise SSL Engine '%s'", engine); failf(data, "Failed to initialise SSL Engine '%s'", engine);
return (CURLE_SSL_ENGINE_INITFAILED); return (CURLE_SSL_ENGINE_INITFAILED);
} }
data->engine = e; data->state.engine = e;
return (CURLE_OK); return (CURLE_OK);
#else #else
failf(data, "SSL Engine not supported"); failf(data, "SSL Engine not supported");
@ -518,12 +518,12 @@ 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)
{ {
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H) #if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
if (data->engine) { if (data->state.engine) {
if (ENGINE_set_default(data->engine, ENGINE_METHOD_ALL) > 0) { if (ENGINE_set_default(data->state.engine, ENGINE_METHOD_ALL) > 0) {
infof(data,"set default crypto engine %s\n", data->engine); infof(data,"set default crypto engine %s\n", data->state.engine);
} }
else { else {
failf(data, "set default crypto engine %s failed", data->engine); failf(data, "set default crypto engine %s failed", data->state.engine);
return CURLE_SSL_ENGINE_SETFAILED; return CURLE_SSL_ENGINE_SETFAILED;
} }
} }
@ -534,7 +534,7 @@ CURLcode Curl_SSL_set_engine_default(struct SessionHandle *data)
} }
/* Build the list of OpenSSL crypto engine names. Add to /* Build the list of OpenSSL crypto engine names. Add to
* linked list at data->engine_list. * linked list at data->state.engine_list.
*/ */
CURLcode Curl_SSL_engines_list(struct SessionHandle *data) CURLcode Curl_SSL_engines_list(struct SessionHandle *data)
{ {
@ -542,12 +542,12 @@ CURLcode Curl_SSL_engines_list(struct SessionHandle *data)
ENGINE *e; ENGINE *e;
/* Free previous list */ /* Free previous list */
if (data->engine_list) if (data->state.engine_list)
curl_slist_free_all(data->engine_list); curl_slist_free_all(data->state.engine_list);
data->engine_list = NULL; 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->engine_list = curl_slist_append(data->engine_list, ENGINE_get_id(e)); data->state.engine_list = curl_slist_append(data->state.engine_list, ENGINE_get_id(e));
#endif #endif
return (CURLE_OK); return (CURLE_OK);
} }
@ -691,14 +691,14 @@ int Curl_SSL_Close_All(struct SessionHandle *data)
free(data->state.session); free(data->state.session);
} }
#ifdef HAVE_OPENSSL_ENGINE_H #ifdef HAVE_OPENSSL_ENGINE_H
if(data->engine) { if(data->state.engine) {
ENGINE_finish(data->engine); ENGINE_finish(data->state.engine);
ENGINE_free(data->engine); ENGINE_free(data->state.engine);
data->engine = NULL; data->state.engine = NULL;
} }
if (data->engine_list) if (data->state.engine_list)
curl_slist_free_all(data->engine_list); curl_slist_free_all(data->state.engine_list);
data->engine_list = NULL; data->state.engine_list = NULL;
#endif #endif
return 0; return 0;
@ -1558,4 +1558,3 @@ Curl_SSLConnect(struct connectdata *conn,
#endif #endif
return retcode; return retcode;
} }

@ -777,6 +777,12 @@ struct UrlState {
#ifdef USE_ARES #ifdef USE_ARES
ares_channel areschannel; /* for name resolves */ ares_channel areschannel; /* for name resolves */
#endif #endif
#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() */
}; };
@ -973,10 +979,6 @@ struct SessionHandle {
struct UrlState state; /* struct for fields used for state info and struct UrlState state; /* struct for fields used for state info and
other dynamic purposes */ other dynamic purposes */
struct PureInfo info; /* stats, reports and info data */ struct PureInfo info; /* stats, reports and info data */
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
ENGINE *engine;
struct curl_slist *engine_list; /* list of names from ENGINE_get_id() */
#endif /* USE_SSLEAY */
}; };
#define LIBCURL_NAME "libcurl" #define LIBCURL_NAME "libcurl"