Last active
January 9, 2017 22:33
-
-
Save unserializable/c797bbd7d7680433d05f3ceb33c0163f to your computer and use it in GitHub Desktop.
Lists the enabled / available ciphersuites from the running JDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.net.ssl.SSLSocketFactory; | |
import java.util.Set; | |
import static java.util.Arrays.stream; | |
import static java.util.stream.Collectors.toSet; | |
/** | |
* @author Taimo Peelo | |
*/ | |
public class JdkTlsCipherSuiteList { | |
private static final void printJVMInfo() { | |
System.out.println("Java vendor " + System.getProperty("java.vendor")); | |
System.out.println("Java vendor url " + System.getProperty("java.vendor.url")); | |
System.out.println("Java version " + System.getProperty("java.version")); | |
System.out.println("OS architecture " + System.getProperty("os.arch")); | |
System.out.println("OS name " + System.getProperty("os.name")); | |
System.out.println("OS version " + System.getProperty("os.version")); | |
System.out.println("----------------------------"); | |
} | |
public static void main(String[] args) { | |
printJVMInfo(); | |
String hsTargetCS = "TLS_RSA_WITH_AES_128_CBC_SHA256"; | |
SSLSocketFactory ssf = (SSLSocketFactory) SSLSocketFactory.getDefault(); | |
Set<String> enabledSuites = stream(ssf.getDefaultCipherSuites()).collect(toSet()); | |
Set<String> availableSuites = stream(ssf.getSupportedCipherSuites()).collect(toSet()); | |
availableSuites.removeAll(enabledSuites); | |
System.out.println("Enabled by default"); | |
enabledSuites.forEach(cs -> | |
System.out.println(" * " + cs) | |
); | |
System.out.println("Available (but not enabled)!"); | |
availableSuites.forEach(cs -> | |
System.out.println(" _ " + cs) | |
); | |
if (enabledSuites.contains(hsTargetCS)) | |
System.out.println( | |
"* Client using the current SDK is able to " + | |
"handshake+talk to server using '" + hsTargetCS + "'" | |
); | |
if (availableSuites.contains(hsTargetCS)) | |
System.out.println( | |
"_ Client with the current SDK WOULD be able to talk to server " + | |
"when ciphersuite + '" + hsTargetCS + "'' is enabled!" | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample run from Oracle 1.8.0_111 SDK