8272163: Add -version option to keytool and jarsigner

Reviewed-by: weijun
This commit is contained in:
Hai-May Chao 2021-10-22 20:53:38 +00:00
parent 6523c558d9
commit fec470f262
6 changed files with 213 additions and 1 deletions

View file

@ -262,6 +262,7 @@ public final class Main {
ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V),
SHOWINFO("showinfo.command.help",
TLS, V),
VERSION("Prints.the.program.version"),
// Undocumented start here, KEYCLONE is used a marker in -help;
@ -717,7 +718,7 @@ public final class Main {
}
boolean isKeyStoreRelated(Command cmd) {
return cmd != PRINTCERTREQ && cmd != SHOWINFO;
return cmd != PRINTCERTREQ && cmd != SHOWINFO && cmd != VERSION;
}
/**
@ -1337,6 +1338,8 @@ public final class Main {
doPrintCRL(filename, out);
} else if (command == SHOWINFO) {
doShowInfo();
} else if (command == VERSION) {
doPrintVersion();
}
// If we need to save the keystore, do so.
@ -2794,6 +2797,10 @@ public final class Main {
}
}
private void doPrintVersion() {
System.out.println("keytool " + System.getProperty("java.version"));
}
private Collection<? extends Certificate> generateCertificates(InputStream in)
throws CertificateException, IOException {
byte[] data = in.readAllBytes();