CLI: Improve the selfsignedgenerator usage help

This commit is contained in:
zzz
2025-01-12 11:17:12 -05:00
parent d51da9e225
commit 64869653a7
2 changed files with 27 additions and 14 deletions

View File

@ -682,18 +682,7 @@ public class SU3File {
/** @since 0.9.9 */
private static String dumpTypes() {
StringBuilder buf = new StringBuilder(256);
buf.append("Available signature types (-t):\n");
for (SigType t : EnumSet.allOf(SigType.class)) {
if (!t.isAvailable())
continue;
if (t == SigType.EdDSA_SHA512_Ed25519 ||
t == SigType.RedDSA_SHA512_Ed25519)
continue; // not supported by keytool, and does double hashing right now
buf.append(" ").append(t).append("\t(code: ").append(t.getCode()).append(')');
if (t.getCode() == DEFAULT_SIG_CODE)
buf.append(" DEFAULT");
buf.append('\n');
}
dumpSigTypes(buf);
buf.append("Available content types (-c):\n");
for (ContentType t : EnumSet.allOf(ContentType.class)) {
buf.append(" ").append(t).append("\t(code: ").append(t.getCode()).append(')');
@ -713,6 +702,24 @@ public class SU3File {
return buf.toString();
}
/**
* @since 0.9.65 split out from above for SelfSignedGenerator.usage()
*/
static void dumpSigTypes(StringBuilder buf) {
buf.append("Available signature types (-t):\n");
for (SigType t : EnumSet.allOf(SigType.class)) {
if (!t.isAvailable())
continue;
if (t == SigType.EdDSA_SHA512_Ed25519 ||
t == SigType.RedDSA_SHA512_Ed25519)
continue; // not supported by keytool, and does double hashing right now
buf.append(" ").append(t).append("\t(code: ").append(t.getCode()).append(')');
if (t.getCode() == DEFAULT_SIG_CODE)
buf.append(" DEFAULT");
buf.append('\n');
}
}
/**
* @param ctype number or name
* @return null if not found

View File

@ -1022,9 +1022,15 @@ public final class SelfSignedGenerator {
}
private static void usage() {
System.err.println("Usage: selfsignedgenerator keygen [-t type|code] [-p keystorepw] [-r crlFile.crl] publicKeyFile.crt keystore.ks localhost\n" +
" selfsignedgenerator renew [-p keystorepw] publicKeyFile.crt keystore.ks");
System.err.println("Usage: selfsignedgenerator keygen [-t type|code] [-p keystorepw] [-r crlFile.crl] publicKeyFile.crt keystore.ks hostname\n" +
" selfsignedgenerator keygen [-t type|code] [-p keystorepw] [-r crlFile.crl] publicKeyFile.crt keystore.ks you@mail.i2p\n" +
" selfsignedgenerator renew [-p keystorepw] newPublicKeyFile.crt keystore.ks");
StringBuilder buf = new StringBuilder(256);
SU3File.dumpSigTypes(buf);
System.err.println(buf.toString());
System.err.println("Default keystore password: \"" + KeyStoreUtil.DEFAULT_KEYSTORE_PASSWORD + '"');
}
/****
private static final void test(String name, SigType type) throws Exception {
Object[] rv = generate("cname@example.com", "ou", "o", null, "st", "c", 3652, type);