mirror of
https://github.com/mtrojnar/osslsigncode.git
synced 2025-07-02 19:22:47 -05:00
Support loading arbitrary engines via ENGINE_by_id()
Use ENGINE_by_id() for any engine name that doesn't contain a dot, assuming it's an engine ID. If the name includes a dot (e.g., a file extension), treat it as a path to a dynamic engine module. See #436 for discussion.
This commit is contained in:
@ -4166,21 +4166,6 @@ static ENGINE *engine_dynamic(GLOBAL_OPTIONS *options)
|
||||
return engine;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load a pkcs11 engine
|
||||
* [in] none
|
||||
* [returns] pointer to ENGINE
|
||||
*/
|
||||
static ENGINE *engine_pkcs11(void)
|
||||
{
|
||||
ENGINE *engine = ENGINE_by_id("pkcs11");
|
||||
if (!engine) {
|
||||
fprintf(stderr, "Failed to find and load 'pkcs11' engine\n");
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
return engine; /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* Load the private key and the signer certificate from a security token
|
||||
* [in, out] options: structure holds the input data
|
||||
@ -4260,12 +4245,18 @@ static int read_token(GLOBAL_OPTIONS *options, ENGINE *engine)
|
||||
|
||||
static int engine_load(GLOBAL_OPTIONS *options)
|
||||
{
|
||||
const char *id = options->p11engine ? options->p11engine : "pkcs11";
|
||||
ENGINE *engine;
|
||||
|
||||
if (options->p11engine)
|
||||
if (strchr(id, '.')) {
|
||||
/* Treat strings with a dot as paths to dynamic engine modules */
|
||||
engine = engine_dynamic(options);
|
||||
else
|
||||
engine = engine_pkcs11();
|
||||
} else {
|
||||
/* Treat strings without a dot as engine IDs */
|
||||
engine = ENGINE_by_id(id);
|
||||
if (!engine)
|
||||
fprintf(stderr, "Failed to find and load '%s' engine\n", id);
|
||||
}
|
||||
if (!engine)
|
||||
return 0; /* FAILED */
|
||||
printf("Engine \"%s\" set.\n", ENGINE_get_id(engine));
|
||||
|
Reference in New Issue
Block a user