mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
Add 'methods' parameter to setup_engine() in apps.c for individual method defaults
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/4277)
This commit is contained in:
parent
8c10e1b660
commit
538404d218
@ -61,13 +61,6 @@ static int read_config(void);
|
||||
static CONF *conf = NULL; /* OpenSSL config file context structure */
|
||||
static OSSL_CMP_CTX *cmp_ctx = NULL; /* the client-side CMP context */
|
||||
|
||||
/* TODO remove when new setup_engine_flags() is in apps/lib/apps.c (PR #4277) */
|
||||
static
|
||||
ENGINE *setup_engine_flags(const char *engine, unsigned int flags, int debug)
|
||||
{
|
||||
return setup_engine(engine, debug);
|
||||
}
|
||||
|
||||
/* the type of cmp command we want to send */
|
||||
typedef enum {
|
||||
CMP_IR,
|
||||
@ -2938,7 +2931,7 @@ int cmp_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (opt_engine != NULL)
|
||||
e = setup_engine_flags(opt_engine, 0 /* not: ENGINE_METHOD_ALL */, 0);
|
||||
e = setup_engine_methods(opt_engine, 0 /* not: ENGINE_METHOD_ALL */, 0);
|
||||
|
||||
if (opt_port != NULL) {
|
||||
if (opt_use_mock_srv) {
|
||||
|
@ -41,7 +41,7 @@
|
||||
* this is true for some implementations of the is*() functions, for
|
||||
* example.
|
||||
*/
|
||||
#define _UC(c) ((unsigned char)(c))
|
||||
# define _UC(c) ((unsigned char)(c))
|
||||
|
||||
void app_RAND_load_conf(CONF *c, const char *section);
|
||||
void app_RAND_write(void);
|
||||
@ -126,7 +126,7 @@ __owur int ctx_set_verify_locations(SSL_CTX *ctx,
|
||||
const char *CApath, int noCApath,
|
||||
const char *CAstore, int noCAstore);
|
||||
|
||||
#ifndef OPENSSL_NO_CT
|
||||
# ifndef OPENSSL_NO_CT
|
||||
|
||||
/*
|
||||
* Sets the file to load the Certificate Transparency log list from.
|
||||
@ -135,9 +135,10 @@ __owur int ctx_set_verify_locations(SSL_CTX *ctx,
|
||||
*/
|
||||
__owur int ctx_set_ctlog_list_file(SSL_CTX *ctx, const char *path);
|
||||
|
||||
#endif
|
||||
# endif
|
||||
|
||||
ENGINE *setup_engine(const char *engine, int debug);
|
||||
ENGINE *setup_engine_methods(const char *id, unsigned int methods, int debug);
|
||||
# define setup_engine(e, debug) setup_engine_methods(e, (unsigned int)-1, debug)
|
||||
void release_engine(ENGINE *e);
|
||||
|
||||
# ifndef OPENSSL_NO_OCSP
|
||||
|
@ -1115,29 +1115,28 @@ static ENGINE *try_load_engine(const char *engine)
|
||||
}
|
||||
#endif
|
||||
|
||||
ENGINE *setup_engine(const char *engine, int debug)
|
||||
ENGINE *setup_engine_methods(const char *id, unsigned int methods, int debug)
|
||||
{
|
||||
ENGINE *e = NULL;
|
||||
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (engine != NULL) {
|
||||
if (strcmp(engine, "auto") == 0) {
|
||||
if (id != NULL) {
|
||||
if (strcmp(id, "auto") == 0) {
|
||||
BIO_printf(bio_err, "Enabling auto ENGINE support\n");
|
||||
ENGINE_register_all_complete();
|
||||
return NULL;
|
||||
}
|
||||
if ((e = ENGINE_by_id(engine)) == NULL
|
||||
&& (e = try_load_engine(engine)) == NULL) {
|
||||
BIO_printf(bio_err, "Invalid engine \"%s\"\n", engine);
|
||||
if ((e = ENGINE_by_id(id)) == NULL
|
||||
&& (e = try_load_engine(id)) == NULL) {
|
||||
BIO_printf(bio_err, "Invalid engine \"%s\"\n", id);
|
||||
ERR_print_errors(bio_err);
|
||||
return NULL;
|
||||
}
|
||||
if (debug) {
|
||||
ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM, 0, bio_err, 0);
|
||||
}
|
||||
ENGINE_ctrl_cmd(e, "SET_USER_INTERFACE", 0, (void *)get_ui_method(),
|
||||
0, 1);
|
||||
if (!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
|
||||
if (debug)
|
||||
(void)ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM, 0, bio_err, 0);
|
||||
if (!ENGINE_ctrl_cmd(e, "SET_USER_INTERFACE", 0,
|
||||
(void *)get_ui_method(), 0, 1)
|
||||
|| !ENGINE_set_default(e, methods)) {
|
||||
BIO_printf(bio_err, "Cannot use engine \"%s\"\n", ENGINE_get_id(e));
|
||||
ERR_print_errors(bio_err);
|
||||
ENGINE_free(e);
|
||||
|
@ -1576,7 +1576,9 @@ int s_server_main(int argc, char *argv[])
|
||||
session_id_prefix = opt_arg();
|
||||
break;
|
||||
case OPT_ENGINE:
|
||||
engine = setup_engine(opt_arg(), 1);
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
engine = setup_engine(opt_arg(), s_debug);
|
||||
#endif
|
||||
break;
|
||||
case OPT_R_CASES:
|
||||
if (!opt_rand(o))
|
||||
|
Loading…
Reference in New Issue
Block a user