aboutsummaryrefslogtreecommitdiffstats
path: root/apps/apps.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2001-06-18 06:22:33 +0000
committerRichard Levitte <levitte@openssl.org>2001-06-18 06:22:33 +0000
commit531d630b5cfe0c50de122f0387a65473b4746bf8 (patch)
treef74f6b2b970014bb6496b9e3fa10a6f701eb936c /apps/apps.c
parent853b1eb424bf60a8ddebdd01baa5af0cc6e204d4 (diff)
downloadopenssl-531d630b5cfe0c50de122f0387a65473b4746bf8.tar.gz
Provide an application-common setup function for engines and use it
everywhere.
Diffstat (limited to 'apps/apps.c')
-rw-r--r--apps/apps.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/apps/apps.c b/apps/apps.c
index 659a3ad7fd..dd19a4cc3a 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -1037,3 +1037,32 @@ X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath)
X509_STORE_free(store);
return NULL;
}
+
+ENGINE *setup_engine(BIO *err, const char *engine, int debug)
+ {
+ ENGINE *e = NULL;
+
+ if (engine)
+ {
+ if((e = ENGINE_by_id(engine)) == NULL)
+ {
+ BIO_printf(err,"invalid engine \"%s\"\n", engine);
+ return NULL;
+ }
+ if (debug)
+ {
+ ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM,
+ 0, err, 0);
+ }
+ ENGINE_ctrl_cmd(e, "SET_USER_INTERFACE", 0, UI_OpenSSL(), 0, 1);
+ if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
+ {
+ BIO_printf(err,"can't use that engine\n");
+ return NULL;
+ }
+ BIO_printf(err,"engine \"%s\" set.\n", engine);
+ /* Free our "structural" reference. */
+ ENGINE_free(e);
+ }
+ return e;
+ }