Package com.unboundid.util.ssl
Class TLSCipherSuiteSelector
java.lang.Object
com.unboundid.util.CommandLineTool
com.unboundid.util.ssl.TLSCipherSuiteSelector
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class TLSCipherSuiteSelector
extends CommandLineTool
This class provides a utility for selecting the cipher suites that should be
supported for TLS communication. The logic used to select the recommended
TLS cipher suites is as follows:
Also note that this class can be used as a command-line tool for debugging purposes.
-
In most JVMs, only cipher suites that use the TLS protocol will be
recommended (that is, suites that use a prefix of "TLS_"), and legacy SSL
suites (those that use a prefix of "SSL_") will not be recommended, nor
will any suites that use an unrecognized protocol. Note that this
restriction will not be enforced for JVMs in which the vendor string
contains "IBM" (as they tend to use "SSL_" prefixes for most or all
cipher suites), or if the
PROPERTY_ALLOW_SSL_PREFIXsystem property is set totrue. - Any cipher suite that uses a NULL key exchange, authentication, bulk encryption, or digest algorithm will not be recommended.
- Any cipher suite that uses anonymous authentication will not be recommended.
- Any cipher suite that uses weakened export-grade encryption will not be recommended.
- By default, only cipher suites that use the ECDHE or DHE key exchange algorithms will be recommended, as they allow for forward secrecy. Suites that use RSA key exchange algorithms (which don't support forward secrecy) will only be recommended if the JVM doesn't support either TLSv1.3 or TLSv1.2, or if overridden programmatically or by system property. Other key agreement algorithms (like ECDH, DH, and KRB5) will not be recommended. Similarly, cipher suites that use a pre-shared key or password will not be recommended.
- Only cipher suites that use AES or ChaCha20 bulk encryption ciphers will be recommended. Other bulk cipher algorithms (like RC4, DES, 3DES, IDEA, Camellia, and ARIA) will not be recommended.
- By default, only cipher suites that use SHA-2 digests will be recommended. SHA-1 suites will only be recommended if the JVM doesn't support either TLSv1.3 or TLSv1.2, or if overridden programmatically or by system property. All other digest algorithms (like MD5) will not be recommended.
Also note that this class can be used as a command-line tool for debugging purposes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of a system property (com.unboundid.util.ssl.TLSCipherSuiteSelector.allowRSAKeyExchange) that can be used to indicate whether to recommend cipher suites that use the RSA key exchange algorithm.static final StringThe name of a system property (com.unboundid.util.ssl.TLSCipherSuiteSelector.allowSHA1) that can be used to indicate whether to recommend cipher suites that use the SHA-1 digest algorithm.static final StringThe name of a system property (com.unboundid.util.ssl.TLSCipherSuiteSelector.allowSSLPrefix) that can be used to indicate whether to recommend cipher suites that use a prefix of "SSL_" rather than "TLS_". -
Constructor Summary
ConstructorsConstructorDescriptionTLSCipherSuiteSelector(OutputStream out, OutputStream err) Creates a new instance of this TLS cipher suite selector that will use the provided output streams.TLSCipherSuiteSelector(OutputStream out, OutputStream err, boolean useJVMDefaults) Creates a new instance of this TLS cipher suite selector that will use the provided output streams. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToolArguments(ArgumentParser parser) Adds the command-line arguments supported for use with this tool to the provided argument parser.static booleanIndicates whether cipher suites that use the RSA key exchange algorithm should be recommended by default.static booleanIndicates whether cipher suites that use the SHA-1 digest algorithm should be recommended by default.static booleanIndicates whether cipher suites whose names start with "SSL_" should be recommended by default.Performs the core set of processing for this tool.Retrieves the set of TLS cipher suites enabled by default in the JVM.Retrieves a map containing the TLS cipher suites that are supported by the JVM but are not recommended for use.static String[]Retrieves an array containing the recommended set of TLS cipher suites as selected by this class.Retrieves the recommended set of TLS cipher suites as selected by this class.Retrieves the set of all TLS cipher suites supported by the JVM.Retrieves a human-readable description for this tool.Retrieves the name of this tool.Retrieves a version string for this tool, if available.static ResultCodemain(OutputStream out, OutputStream err, String... args) Invokes this command-line program with the provided set of arguments.static voidInvokes this command-line program with the provided set of arguments.static voidRe-computes the default instance of this cipher suite selector.selectSupportedCipherSuites(Collection<String> potentialSuiteNames) Filters the provided collection of potential cipher suite names to retrieve a set of the suites that are supported by the JVM.static voidsetAllowRSAKeyExchange(boolean allowRSAKeyExchange) Specifies whether cipher suites that use the RSA key exchange algorithm should be recommended by default.static voidsetAllowSHA1(boolean allowSHA1) Specifies whether cipher suites that use the SHA-1 digest algorithm should be recommended by default.static voidsetAllowSSLPrefixedSuites(boolean allowSSLPrefix) Specifies whether cipher suites whose names start with "SSL_" should be recommended by default.Methods inherited from class com.unboundid.util.CommandLineTool
addEnableSSLDebuggingArgument, createArgumentParser, defaultsToInteractiveMode, doExtendedArgumentValidation, doShutdownHookProcessing, err, getAdditionalDescriptionParagraphs, getErr, getExampleUsages, getMaxTrailingArguments, getMinTrailingArguments, getOriginalErr, getOriginalOut, getOut, getPasswordFileReader, getToolCompletionMessage, getTrailingArgumentsPlaceholder, logToolInvocationByDefault, out, registerShutdownHook, requestToolArgumentsInteractively, runTool, supportsDebugLogging, supportsInteractiveMode, supportsOutputFile, supportsPropertiesFile, wrapErr, wrapOut
-
Field Details
-
PROPERTY_ALLOW_RSA_KEY_EXCHANGE
The name of a system property (com.unboundid.util.ssl.TLSCipherSuiteSelector.allowRSAKeyExchange) that can be used to indicate whether to recommend cipher suites that use the RSA key exchange algorithm. RSA key exchange does not support forward secrecy, so it will not be recommended by default unless the JVM doesn't support either TLSv1.3 or TLSv1.2. This can be overridden via thesetAllowRSAKeyExchange(boolean)method. -
PROPERTY_ALLOW_SHA_1
The name of a system property (com.unboundid.util.ssl.TLSCipherSuiteSelector.allowSHA1) that can be used to indicate whether to recommend cipher suites that use the SHA-1 digest algorithm. The SHA-1 digest is now considered weak, so it will not be recommended by default unless the JVM doesn't support either TLSv1.3 or TLSv1.2. This can be overridden via thesetAllowSHA1(boolean)method. -
PROPERTY_ALLOW_SSL_PREFIX
The name of a system property (com.unboundid.util.ssl.TLSCipherSuiteSelector.allowSSLPrefix) that can be used to indicate whether to recommend cipher suites that use a prefix of "SSL_" rather than "TLS_". If this is not specified, then the default behavior will be to disable all suites with an "SSL_" prefix for all non-IBM JVMs, but to allow them for JVMs in which the vendor string contains "IBM", as they are known to use "SSL_" prefixes even for suites that are only in use in conjunction with TLS protocols.
-
-
Constructor Details
-
TLSCipherSuiteSelector
Creates a new instance of this TLS cipher suite selector that will use the provided output streams. Note that this constructor should only be used when invoking it as a command-line tool.- Parameters:
out- The output stream to use for standard output. It may benullif standard output should be suppressed.err- The output stream to use for standard error. It may benullif standard error should be suppressed.
-
TLSCipherSuiteSelector
public TLSCipherSuiteSelector(@Nullable OutputStream out, @Nullable OutputStream err, boolean useJVMDefaults) Creates a new instance of this TLS cipher suite selector that will use the provided output streams. Note that this constructor should only be used when invoking it as a command-line tool.- Parameters:
out- The output stream to use for standard output. It may benullif standard output should be suppressed.err- The output stream to use for standard error. It may benullif standard error should be suppressed.useJVMDefaults- Indicates whether to use the JVM-default settings. This should only betruefor the initial instance created before the static initializer has run.
-
-
Method Details
-
main
Invokes this command-line program with the provided set of arguments.- Parameters:
args- The command-line arguments provided to this program.
-
main
@NotNull public static ResultCode main(@Nullable OutputStream out, @Nullable OutputStream err, @NotNull String... args) Invokes this command-line program with the provided set of arguments.- Parameters:
out- The output stream to use for standard output. It may benullif standard output should be suppressed.err- The output stream to use for standard error. It may benullif standard error should be suppressed.args- The command-line arguments provided to this program.- Returns:
- A result code that indicates whether the processing was successful.
-
getSupportedCipherSuites
Retrieves the set of all TLS cipher suites supported by the JVM. The set will be sorted in order of most preferred to least preferred, as determined by theTLSCipherSuiteComparator.- Returns:
- The set of all TLS cipher suites supported by the JVM.
-
getDefaultCipherSuites
Retrieves the set of TLS cipher suites enabled by default in the JVM. The set will be sorted in order of most preferred to least preferred, as determined by theTLSCipherSuiteComparator.- Returns:
- The set of TLS cipher suites enabled by default in the JVM.
-
getRecommendedCipherSuites
Retrieves the recommended set of TLS cipher suites as selected by this class. The set will be sorted in order of most preferred to least preferred, as determined by theTLSCipherSuiteComparator.- Returns:
- The recommended set of TLS cipher suites as selected by this class.
-
getRecommendedCipherSuiteArray
Retrieves an array containing the recommended set of TLS cipher suites as selected by this class. The array will be sorted in order of most preferred to least preferred, as determined by theTLSCipherSuiteComparator.- Returns:
- An array containing the recommended set of TLS cipher suites as selected by this class.
-
getNonRecommendedCipherSuites
Retrieves a map containing the TLS cipher suites that are supported by the JVM but are not recommended for use. The keys of the map will be the names of the non-recommended cipher suites, sorted in order of most preferred to least preferred, as determined by theTLSCipherSuiteComparator. Each TLS cipher suite name will be mapped to a list of the reasons it is not recommended for use.- Returns:
- A map containing the TLS cipher suites that are supported by the JVM but are not recommended for use
-
getToolName
Retrieves the name of this tool. It should be the name of the command used to invoke this tool.- Specified by:
getToolNamein classCommandLineTool- Returns:
- The name for this tool.
-
getToolDescription
Retrieves a human-readable description for this tool. If the description should include multiple paragraphs, then this method should return the text for the first paragraph, and theCommandLineTool.getAdditionalDescriptionParagraphs()method should be used to return the text for the subsequent paragraphs.- Specified by:
getToolDescriptionin classCommandLineTool- Returns:
- A human-readable description for this tool.
-
getToolVersion
Retrieves a version string for this tool, if available.- Overrides:
getToolVersionin classCommandLineTool- Returns:
- A version string for this tool, or
nullif none is available.
-
addToolArguments
Adds the command-line arguments supported for use with this tool to the provided argument parser. The tool may need to retain references to the arguments (and/or the argument parser, if trailing arguments are allowed) to it in order to obtain their values for use in later processing.- Specified by:
addToolArgumentsin classCommandLineTool- Parameters:
parser- The argument parser to which the arguments are to be added.- Throws:
ArgumentException- If a problem occurs while adding any of the tool-specific arguments to the provided argument parser.
-
doToolProcessing
Performs the core set of processing for this tool.- Specified by:
doToolProcessingin classCommandLineTool- Returns:
- A result code that indicates whether the processing completed successfully.
-
selectSupportedCipherSuites
@NotNull public static Set<String> selectSupportedCipherSuites(@Nullable Collection<String> potentialSuiteNames) Filters the provided collection of potential cipher suite names to retrieve a set of the suites that are supported by the JVM.- Parameters:
potentialSuiteNames- The collection of cipher suite names to be filtered.- Returns:
- The set of provided cipher suites that are supported by the JVM, or an empty set if none of the potential provided suite names are supported by the JVM.
-
allowRSAKeyExchange
Indicates whether cipher suites that use the RSA key exchange algorithm should be recommended by default.- Returns:
trueif cipher suites that use the RSA key exchange algorithm should be recommended by default, orfalseif not.
-
setAllowRSAKeyExchange
Specifies whether cipher suites that use the RSA key exchange algorithm should be recommended by default.- Parameters:
allowRSAKeyExchange- Indicates whether cipher suites that use the RSA key exchange algorithm should be recommended by default.
-
allowSHA1
Indicates whether cipher suites that use the SHA-1 digest algorithm should be recommended by default.- Returns:
trueif cipher suites that use the SHA-1 digest algorithm should be recommended by default, orfalseif not.
-
setAllowSHA1
Specifies whether cipher suites that use the SHA-1 digest algorithm should be recommended by default.- Parameters:
allowSHA1- Indicates whether cipher suites that use the SHA-1 digest algorithm should be recommended by default.
-
allowSSLPrefixedSuites
Indicates whether cipher suites whose names start with "SSL_" should be recommended by default.- Returns:
trueif cipher suites prefixed with either "SSL_" or "TLS_" should be recommended by default, orfalseif only suites prefixed with "TLS_" should be recommended by default.
-
setAllowSSLPrefixedSuites
Specifies whether cipher suites whose names start with "SSL_" should be recommended by default.- Parameters:
allowSSLPrefix- Indicates whether cipher suites whose names start with "SSL_" should be recommended by default. If this istrue, then suites prefixed with either "TLS_" or "SSL_" may be recommended. If this isfalse, then only suites prefixed with "TLS_" may be recommended.
-
recompute
Re-computes the default instance of this cipher suite selector. This may be necessary after certain actions that alter the supported set of TLS cipher suites (for example, installing or removing cryptographic providers).
-