Print all loaded engines with openssl list -engines
authorTomas Mraz <tmraz@fedoraproject.org>
Thu, 7 Mar 2019 14:28:30 +0000 (15:28 +0100)
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Fri, 8 Mar 2019 23:32:04 +0000 (00:32 +0100)
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/8434)

apps/openssl.c
doc/man1/list.pod

index 854f943f665f290875387d3a685ec65e7fa55032..1acae242156257f6fe37918c894b33105ad9de36 100644 (file)
@@ -54,6 +54,7 @@ static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]);
 static void list_pkey(void);
 static void list_pkey_meth(void);
 static void list_type(FUNC_TYPE ft, int one);
 static void list_pkey(void);
 static void list_pkey_meth(void);
 static void list_type(FUNC_TYPE ft, int one);
+static void list_engines(void);
 static void list_disabled(void);
 char *default_config_file = NULL;
 
 static void list_disabled(void);
 char *default_config_file = NULL;
 
@@ -523,8 +524,8 @@ typedef enum HELPLIST_CHOICE {
     OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE,
     OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS,
     OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
     OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE,
     OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS,
     OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
-    OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_DISABLED, OPT_MISSING_HELP,
-    OPT_OBJECTS
+    OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_ENGINES, OPT_DISABLED,
+    OPT_MISSING_HELP, OPT_OBJECTS
 } HELPLIST_CHOICE;
 
 const OPTIONS list_options[] = {
 } HELPLIST_CHOICE;
 
 const OPTIONS list_options[] = {
@@ -544,6 +545,8 @@ const OPTIONS list_options[] = {
      "List of public key algorithms"},
     {"public-key-methods", OPT_PK_METHOD, '-',
      "List of public key methods"},
      "List of public key algorithms"},
     {"public-key-methods", OPT_PK_METHOD, '-',
      "List of public key methods"},
+    {"engines", OPT_ENGINES, '-',
+     "List of loaded engines"},
     {"disabled", OPT_DISABLED, '-',
      "List of disabled features"},
     {"missing-help", OPT_MISSING_HELP, '-',
     {"disabled", OPT_DISABLED, '-',
      "List of disabled features"},
     {"missing-help", OPT_MISSING_HELP, '-',
@@ -599,6 +602,9 @@ opthelp:
         case OPT_PK_METHOD:
             list_pkey_meth();
             break;
         case OPT_PK_METHOD:
             list_pkey_meth();
             break;
+        case OPT_ENGINES:
+            list_engines();
+            break;
         case OPT_DISABLED:
             list_disabled();
             break;
         case OPT_DISABLED:
             list_disabled();
             break;
@@ -837,6 +843,22 @@ static int SortFnByName(const void *_f1, const void *_f2)
     return strcmp(f1->name, f2->name);
 }
 
     return strcmp(f1->name, f2->name);
 }
 
+static void list_engines(void)
+{
+#ifndef OPENSSL_NO_ENGINES
+    ENGINE *e;
+
+    BIO_puts(bio_out, "Engines:\n");
+    e = ENGINE_get_first();
+    while (e) {
+        BIO_printf(bio_out, "%s\n", ENGINE_get_id(e));
+        e = ENGINE_get_next(e);
+    }
+#else
+    BIO_puts(bio_out, "Engine support is disabled.\n");
+#endif
+}
+
 static void list_disabled(void)
 {
     BIO_puts(bio_out, "Disabled algorithms:\n");
 static void list_disabled(void)
 {
     BIO_puts(bio_out, "Disabled algorithms:\n");
index b1a147ba2795f0e21b48ae60c6f1dfda5c73c7fe..901a2668dd57a64a1ecfcb05ea8372dd2607f33f 100644 (file)
@@ -18,6 +18,7 @@ B<openssl list>
 [B<-cipher-algorithms>]
 [B<-public-key-algorithms>]
 [B<-public-key-methods>]
 [B<-cipher-algorithms>]
 [B<-public-key-algorithms>]
 [B<-public-key-methods>]
+[B<-engines>]
 [B<-disabled>]
 
 =head1 DESCRIPTION
 [B<-disabled>]
 
 =head1 DESCRIPTION
@@ -80,6 +81,10 @@ a block of multiple lines, all but the first are indented.
 Display a list of public key method OIDs: this also includes public key methods
 without an associated ASN.1 method, for example, KDF algorithms.
 
 Display a list of public key method OIDs: this also includes public key methods
 without an associated ASN.1 method, for example, KDF algorithms.
 
+=item B<-engines>
+
+Display a list of loaded engines.
+
 =item B<-disabled>
 
 Display a list of disabled features, those that were compiled out
 =item B<-disabled>
 
 Display a list of disabled features, those that were compiled out