Commit 531d630b authored by Richard Levitte's avatar Richard Levitte
Browse files

Provide an application-common setup function for engines and use it

everywhere.
parent 853b1eb4
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -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;
        }
+1 −0
Original line number Diff line number Diff line
@@ -176,6 +176,7 @@ EVP_PKEY *load_pubkey(BIO *err, const char *file, int format,
STACK_OF(X509) *load_certs(BIO *err, const char *file, int format,
	const char *pass, ENGINE *e, const char *cert_descrip);
X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath);
ENGINE *setup_engine(BIO *err, const char *engine, int debug);

#define FORMAT_UNDEF    0
#define FORMAT_ASN1     1
+1 −17
Original line number Diff line number Diff line
@@ -549,23 +549,7 @@ bad:

	ERR_load_crypto_strings();

	if (engine != NULL)
		{
		if ((e = ENGINE_by_id(engine)) == NULL)
			{
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
				engine);
			goto err;
			}
		if (!ENGINE_set_default(e, ENGINE_METHOD_ALL))
			{
			BIO_printf(bio_err,"can't use that engine\n");
			goto err;
			}
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
		/* Free our "structural" reference. */
		ENGINE_free(e);
		}
        e = setup_engine(bio_err, engine, 0);

	/*****************************************************************/
	if (configfile == NULL) configfile = getenv("OPENSSL_CONF");
+1 −17
Original line number Diff line number Diff line
@@ -225,23 +225,7 @@ int MAIN(int argc, char **argv)
		goto end;
		}

	if (engine != NULL)
		{
		if((e = ENGINE_by_id(engine)) == NULL)
			{
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
				engine);
			goto end;
			}
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
			{
			BIO_printf(bio_err,"can't use that engine\n");
			goto end;
			}
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
		/* Free our "structural" reference. */
		ENGINE_free(e);
		}
        e = setup_engine(bio_err, engine, 0);

	in=BIO_new(BIO_s_file());
	bmd=BIO_new(BIO_f_md());
+1 −17
Original line number Diff line number Diff line
@@ -174,23 +174,7 @@ bad:

	ERR_load_crypto_strings();

	if (engine != NULL)
		{
		if((e = ENGINE_by_id(engine)) == NULL)
			{
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
				engine);
			goto end;
			}
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
			{
			BIO_printf(bio_err,"can't use that engine\n");
			goto end;
			}
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
		/* Free our "structural" reference. */
		ENGINE_free(e);
		}
        e = setup_engine(bio_err, engine, 0);

	in=BIO_new(BIO_s_file());
	out=BIO_new(BIO_s_file());
Loading