Programming Tips - Java: get supported SSL/TLS protocols

Date: 2023jan19 Language: Java Q. Java: get supported SSL/TLS protocols A.
String protocols[] = SSLContext.getDefault().getSupportedSSLParameters().getProtocols();
This includes SSL protocols which are obsolete so you can do:
HashSet<String> getTlsProtocols() { HashSet<String> set = new HashSet<>(); try { String protocols[] = SSLContext.getDefault().getSupportedSSLParameters().getProtocols(); for (String protocol : protocols) { if (protocol.startsWith("TLS")) { set.add(protocol); } } } catch (NoSuchAlgorithmException ex) { // Fall thru } return set; }