apps x509: passing PKCS#11 URL as -signkey
[openssl.git] / apps / ts.c
index 9fdba649c1683583ba94fca48ab467068dd9970a..c651c8e5cd612706a6051015736d27888db13aef 100644 (file)
--- a/apps/ts.c
+++ b/apps/ts.c
@@ -90,39 +90,43 @@ typedef enum OPTION_choice {
 } OPTION_CHOICE;
 
 const OPTIONS ts_options[] = {
+    OPT_SECTION("General"),
     {"help", OPT_HELP, '-', "Display this summary"},
     {"config", OPT_CONFIG, '<', "Configuration file"},
     {"section", OPT_SECTION, 's', "Section to use within config file"},
-    {"query", OPT_QUERY, '-', "Generate a TS query"},
-    {"data", OPT_DATA, '<', "File to hash"},
-    {"digest", OPT_DIGEST, 's', "Digest (as a hex string)"},
-    OPT_R_OPTIONS,
-    {"tspolicy", OPT_TSPOLICY, 's', "Policy OID to use"},
-    {"no_nonce", OPT_NO_NONCE, '-', "Do not include a nonce"},
-    {"cert", OPT_CERT, '-', "Put cert request into query"},
-    {"in", OPT_IN, '<', "Input file"},
-    {"token_in", OPT_TOKEN_IN, '-', "Input is a PKCS#7 file"},
-    {"out", OPT_OUT, '>', "Output file"},
-    {"token_out", OPT_TOKEN_OUT, '-', "Output is a PKCS#7 file"},
-    {"text", OPT_TEXT, '-', "Output text (not DER)"},
-    {"reply", OPT_REPLY, '-', "Generate a TS reply"},
-    {"queryfile", OPT_QUERYFILE, '<', "File containing a TS query"},
-    {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
+# ifndef OPENSSL_NO_ENGINE
+    {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
+# endif
     {"inkey", OPT_INKEY, 's', "File with private key for reply"},
     {"signer", OPT_SIGNER, 's', "Signer certificate file"},
     {"chain", OPT_CHAIN, '<', "File with signer CA chain"},
-    {"verify", OPT_VERIFY, '-', "Verify a TS response"},
     {"CApath", OPT_CAPATH, '/', "Path to trusted CA files"},
     {"CAfile", OPT_CAFILE, '<', "File with trusted CA certs"},
     {"CAstore", OPT_CASTORE, ':', "URI to trusted CA store"},
     {"untrusted", OPT_UNTRUSTED, '<', "File with untrusted certs"},
+    {"token_in", OPT_TOKEN_IN, '-', "Input is a PKCS#7 file"},
+    {"token_out", OPT_TOKEN_OUT, '-', "Output is a PKCS#7 file"},
+    {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
     {"", OPT_MD, '-', "Any supported digest"},
-# ifndef OPENSSL_NO_ENGINE
-    {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
-# endif
-    {OPT_HELP_STR, 1, '-', "\nOptions specific to 'ts -verify': \n"},
+
+    OPT_SECTION("Query"),
+    {"query", OPT_QUERY, '-', "Generate a TS query"},
+    {"data", OPT_DATA, '<', "File to hash"},
+    {"digest", OPT_DIGEST, 's', "Digest (as a hex string)"},
+    {"queryfile", OPT_QUERYFILE, '<', "File containing a TS query"},
+    {"cert", OPT_CERT, '-', "Put cert request into query"},
+    {"in", OPT_IN, '<', "Input file"},
+
+    OPT_SECTION("Verify"),
+    {"verify", OPT_VERIFY, '-', "Verify a TS response"},
+    {"reply", OPT_REPLY, '-', "Generate a TS reply"},
+    {"tspolicy", OPT_TSPOLICY, 's', "Policy OID to use"},
+    {"no_nonce", OPT_NO_NONCE, '-', "Do not include a nonce"},
+    {"out", OPT_OUT, '>', "Output file"},
+    {"text", OPT_TEXT, '-', "Output text (not DER)"},
+
+    OPT_R_OPTIONS,
     OPT_V_OPTIONS,
-    {OPT_HELP_STR, 1, '-', "\n"},
     {NULL}
 };
 
@@ -130,26 +134,26 @@ const OPTIONS ts_options[] = {
  * This command is so complex, special help is needed.
  */
 static char* opt_helplist[] = {
+    "",
     "Typical uses:",
-    "ts -query [-rand file...] [-config file] [-data file]",
-    "          [-digest hexstring] [-tspolicy oid] [-no_nonce] [-cert]",
-    "          [-in file] [-out file] [-text]",
-    "  or",
-    "ts -reply [-config file] [-section tsa_section]",
-    "          [-queryfile file] [-passin password]",
-    "          [-signer tsa_cert.pem] [-inkey private_key.pem]",
-    "          [-chain certs_file.pem] [-tspolicy oid]",
-    "          [-in file] [-token_in] [-out file] [-token_out]",
+    " openssl ts -query [-rand file...] [-config file] [-data file]",
+    "    [-digest hexstring] [-tspolicy oid] [-no_nonce] [-cert]",
+    "    [-in file] [-out file] [-text]",
+    "",
+    " openssl ts -reply [-config file] [-section tsa_section]",
+    "    [-queryfile file] [-passin password]",
+    "    [-signer tsa_cert.pem] [-inkey private_key.pem]",
+    "    [-chain certs_file.pem] [-tspolicy oid]",
+    "    [-in file] [-token_in] [-out file] [-token_out]",
 # ifndef OPENSSL_NO_ENGINE
-    "          [-text] [-engine id]",
+    "    [-text] [-engine id]",
 # else
-    "          [-text]",
+    "    [-text]",
 # endif
-    "  or",
-    "ts -verify -CApath dir -CAfile file.pem -CAstore uri -untrusted file.pem",
-    "           [-data file] [-digest hexstring]",
-    "           [-queryfile file] -in file [-token_in]",
-    "           [[options specific to 'ts -verify']]",
+    "",
+    " openssl ts -verify -CApath dir -CAfile file.pem -CAstore uri",
+    "   -untrusted file.pem [-data file] [-digest hexstring]",
+    "    [-queryfile file] -in file [-token_in] ...",
     NULL,
 };
 
@@ -289,7 +293,8 @@ int ts_main(int argc, char **argv)
         goto end;
     }
 
-    conf = load_config_file(configfile);
+    if ((conf = load_config_file(configfile)) == NULL)
+        goto end;
     if (configfile != default_config_file && !app_load_modules(conf))
         goto end;