提交 66e59702 编写于 作者: L Luke Faraone 提交者: Rich Salz

Add support for using engine-backed keys in spkac

Reviewed-by: NMatt Caswell <matt@openssl.org>
Reviewed-by: NRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3599)
上级 bd91e3c8
...@@ -24,7 +24,7 @@ typedef enum OPTION_choice { ...@@ -24,7 +24,7 @@ typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_NOOUT, OPT_PUBKEY, OPT_VERIFY, OPT_IN, OPT_OUT, OPT_NOOUT, OPT_PUBKEY, OPT_VERIFY, OPT_IN, OPT_OUT,
OPT_ENGINE, OPT_KEY, OPT_CHALLENGE, OPT_PASSIN, OPT_SPKAC, OPT_ENGINE, OPT_KEY, OPT_CHALLENGE, OPT_PASSIN, OPT_SPKAC,
OPT_SPKSECT OPT_SPKSECT, OPT_KEYFORM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS spkac_options[] = { const OPTIONS spkac_options[] = {
...@@ -32,6 +32,7 @@ const OPTIONS spkac_options[] = { ...@@ -32,6 +32,7 @@ const OPTIONS spkac_options[] = {
{"in", OPT_IN, '<', "Input file"}, {"in", OPT_IN, '<', "Input file"},
{"out", OPT_OUT, '>', "Output file"}, {"out", OPT_OUT, '>', "Output file"},
{"key", OPT_KEY, '<', "Create SPKAC using private key"}, {"key", OPT_KEY, '<', "Create SPKAC using private key"},
{"keyform", OPT_KEYFORM, 'f', "Private key file format - default PEM (PEM, DER, or ENGINE)"},
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
{"challenge", OPT_CHALLENGE, 's', "Challenge string"}, {"challenge", OPT_CHALLENGE, 's', "Challenge string"},
{"spkac", OPT_SPKAC, 's', "Alternative SPKAC name"}, {"spkac", OPT_SPKAC, 's', "Alternative SPKAC name"},
...@@ -58,6 +59,7 @@ int spkac_main(int argc, char **argv) ...@@ -58,6 +59,7 @@ int spkac_main(int argc, char **argv)
char *spkstr = NULL, *prog; char *spkstr = NULL, *prog;
const char *spkac = "SPKAC", *spksect = "default"; const char *spkac = "SPKAC", *spksect = "default";
int i, ret = 1, verify = 0, noout = 0, pubkey = 0; int i, ret = 1, verify = 0, noout = 0, pubkey = 0;
int keyformat = FORMAT_PEM;
OPTION_CHOICE o; OPTION_CHOICE o;
prog = opt_init(argc, argv, spkac_options); prog = opt_init(argc, argv, spkac_options);
...@@ -93,6 +95,10 @@ int spkac_main(int argc, char **argv) ...@@ -93,6 +95,10 @@ int spkac_main(int argc, char **argv)
case OPT_KEY: case OPT_KEY:
keyfile = opt_arg(); keyfile = opt_arg();
break; break;
case OPT_KEYFORM:
if (!opt_format(opt_arg(), OPT_FMT_ANY, &keyformat))
goto opthelp;
break;
case OPT_CHALLENGE: case OPT_CHALLENGE:
challenge = opt_arg(); challenge = opt_arg();
break; break;
...@@ -118,7 +124,7 @@ int spkac_main(int argc, char **argv) ...@@ -118,7 +124,7 @@ int spkac_main(int argc, char **argv)
if (keyfile) { if (keyfile) {
pkey = load_key(strcmp(keyfile, "-") ? keyfile : NULL, pkey = load_key(strcmp(keyfile, "-") ? keyfile : NULL,
FORMAT_PEM, 1, passin, e, "private key"); keyformat, 1, passin, e, "private key");
if (!pkey) { if (!pkey) {
goto end; goto end;
} }
......
...@@ -11,6 +11,7 @@ B<openssl> B<spkac> ...@@ -11,6 +11,7 @@ B<openssl> B<spkac>
[B<-in filename>] [B<-in filename>]
[B<-out filename>] [B<-out filename>]
[B<-key keyfile>] [B<-key keyfile>]
[B<-keyform PEM|DER|ENGINE>]
[B<-passin arg>] [B<-passin arg>]
[B<-challenge string>] [B<-challenge string>]
[B<-pubkey>] [B<-pubkey>]
...@@ -50,6 +51,11 @@ Create an SPKAC file using the private key in B<keyfile>. The ...@@ -50,6 +51,11 @@ Create an SPKAC file using the private key in B<keyfile>. The
B<-in>, B<-noout>, B<-spksect> and B<-verify> options are ignored if B<-in>, B<-noout>, B<-spksect> and B<-verify> options are ignored if
present. present.
=item B<-keyform PEM|DER|ENGINE>
Whether the key format is PEM, DER, or an engine-backed key.
The default is PEM.
=item B<-passin password> =item B<-passin password>
The input file password source. For more information about the format of B<arg> The input file password source. For more information about the format of B<arg>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册