mirror of
https://github.com/mtrojnar/osslsigncode.git
synced 2025-04-18 21:58:05 -05:00
Make -pkcs11engine option optional. (#5)
If not specified, load all builtin engines, most likely the pkcs11 one will be among them. This makes the pkcs11module option much easier to use in the most common use-cases.
This commit is contained in:
parent
bed25dcb7d
commit
044861b323
@ -821,7 +821,7 @@ static void usage(const char *argv0)
|
|||||||
"Usage: %s\n\n\t[ --version | -v ]\n\n"
|
"Usage: %s\n\n\t[ --version | -v ]\n\n"
|
||||||
"\t[ sign ]\n"
|
"\t[ sign ]\n"
|
||||||
"\t\t( -certs <certfile> -key <keyfile> | -pkcs12 <pkcs12file> |\n"
|
"\t\t( -certs <certfile> -key <keyfile> | -pkcs12 <pkcs12file> |\n"
|
||||||
"\t\t -pkcs11engine <engine> -pkcs11module <module> -certs <certfile> -key <pkcs11 key id>)\n"
|
"\t\t [ -pkcs11engine <engine> ] -pkcs11module <module> -certs <certfile> -key <pkcs11 key id>)\n"
|
||||||
"\t\t[ -pass <password> ] "
|
"\t\t[ -pass <password> ] "
|
||||||
#ifdef PROVIDE_ASKPASS
|
#ifdef PROVIDE_ASKPASS
|
||||||
"[ -askpass ]"
|
"[ -askpass ]"
|
||||||
@ -2584,7 +2584,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (argc > 0 || (nturl && ntsurl) || !infile ||
|
if (argc > 0 || (nturl && ntsurl) || !infile ||
|
||||||
(cmd != CMD_VERIFY && !outfile) ||
|
(cmd != CMD_VERIFY && !outfile) ||
|
||||||
(cmd == CMD_SIGN && !((certfile && keyfile) || pkcs12file || (p11engine && p11module)))) {
|
(cmd == CMD_SIGN && !((certfile && keyfile) || pkcs12file || p11module))) {
|
||||||
if (failarg)
|
if (failarg)
|
||||||
fprintf(stderr, "Unknown option: %s\n", failarg);
|
fprintf(stderr, "Unknown option: %s\n", failarg);
|
||||||
usage(argv0);
|
usage(argv0);
|
||||||
@ -2610,7 +2610,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (cmd == CMD_SIGN) {
|
if (cmd == CMD_SIGN) {
|
||||||
/* Read certificate and key */
|
/* Read certificate and key */
|
||||||
if (keyfile && !p11engine && (btmp = BIO_new_file(keyfile, "rb")) != NULL) {
|
if (keyfile && !p11module && (btmp = BIO_new_file(keyfile, "rb")) != NULL) {
|
||||||
unsigned char magic[4];
|
unsigned char magic[4];
|
||||||
unsigned char pvkhdr[4] = { 0x1e, 0xf1, 0xb5, 0xb0 };
|
unsigned char pvkhdr[4] = { 0x1e, 0xf1, 0xb5, 0xb0 };
|
||||||
magic[0] = 0x00;
|
magic[0] = 0x00;
|
||||||
@ -2642,8 +2642,9 @@ int main(int argc, char **argv) {
|
|||||||
(pkey = b2i_PVK_bio(btmp, NULL, NULL)) == NULL))
|
(pkey = b2i_PVK_bio(btmp, NULL, NULL)) == NULL))
|
||||||
DO_EXIT_1("Failed to read PVK file: %s\n", pvkfile);
|
DO_EXIT_1("Failed to read PVK file: %s\n", pvkfile);
|
||||||
BIO_free(btmp);
|
BIO_free(btmp);
|
||||||
} else if (p11engine != NULL && p11module != NULL) {
|
} else if (p11module != NULL) {
|
||||||
const int CMD_MANDATORY = 0;
|
const int CMD_MANDATORY = 0;
|
||||||
|
if (p11engine != NULL) {
|
||||||
ENGINE_load_dynamic();
|
ENGINE_load_dynamic();
|
||||||
ENGINE * dyn = ENGINE_by_id("dynamic");
|
ENGINE * dyn = ENGINE_by_id("dynamic");
|
||||||
if (!dyn)
|
if (!dyn)
|
||||||
@ -2659,6 +2660,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (1 != ENGINE_ctrl_cmd(dyn, "LOAD", 1, NULL, NULL, CMD_MANDATORY))
|
if (1 != ENGINE_ctrl_cmd(dyn, "LOAD", 1, NULL, NULL, CMD_MANDATORY))
|
||||||
DO_EXIT_0("Failed to set dyn LOAD to '1'\n");
|
DO_EXIT_0("Failed to set dyn LOAD to '1'\n");
|
||||||
|
} else
|
||||||
|
ENGINE_load_builtin_engines();
|
||||||
|
|
||||||
ENGINE * pkcs11 = ENGINE_by_id("pkcs11");
|
ENGINE * pkcs11 = ENGINE_by_id("pkcs11");
|
||||||
if (!pkcs11)
|
if (!pkcs11)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user