How to check what SSL Ciphers are supported by your JVM

How to check what SSL Ciphers are supported by your JVM

Hello Team,

If you ever wondered what are the SSL Ciphers supported by your appliaction which running on particular JVM, then you can find it with below program.

Note: Make sure you are switched into user who is allowed to start your application.

Go to /tmp directory and createa file named as Ciphers.java

import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import javax.net.ssl.SSLServerSocketFactory;

public class Ciphers
{
    public static void main(String[] args)
        throws Exception
    {
        SSLServerSocketFactory ssf = (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();

        String[] defaultCiphers = ssf.getDefaultCipherSuites();
        String[] availableCiphers = ssf.getSupportedCipherSuites();

        TreeMap ciphers = new TreeMap();

        for(int i=0; i<availableCiphers.length; ++i )
            ciphers.put(availableCiphers[i], Boolean.FALSE);

        for(int i=0; i<defaultCiphers.length; ++i )
            ciphers.put(defaultCiphers[i], Boolean.TRUE);

        System.out.println("Default\tCipher");
        for(Iterator i = ciphers.entrySet().iterator(); i.hasNext(); ) {
            Map.Entry cipher=(Map.Entry)i.next();

            if(Boolean.TRUE.equals(cipher.getValue()))
                System.out.print('*');
            else
                System.out.print(' ');

            System.out.print('\t');
            System.out.println(cipher.getKey());
        }
    }
}

save the file and execute it with below commands

javac -Xlint:deprecation Ciphers.java
java Ciphers

And you will see all Ciphers supported by your JVM.

Thank you.

Reference: https://confluence.atlassian.com/stashkb/list-ciphers-used-by-jvm-679609085.html


Comments