查询JDK默认支持的SSL/TSL版本
程序员文章站
2022-06-25 11:38:08
...
- public static void main(String[] args) throws Exception {
- SSLContext context = SSLContext.getInstance("TLS");
- context.init(null, null, null);
- SSLSocketFactory factory = (SSLSocketFactory) context.getSocketFactory();
- SSLSocket socket = (SSLSocket) factory.createSocket();
- String[] protocols = socket.getSupportedProtocols();
- System.out.println("Supported Protocols: " + protocols.length);
- for (int i = 0; i < protocols.length; i++) {
- System.out.println(" " + protocols[i]);
- }
- protocols = socket.getEnabledProtocols();
- System.out.println("Enabled Protocols: " + protocols.length);
- for (int i = 0; i < protocols.length; i++) {
- System.out.println(" " + protocols[i]);
- }
- }
推荐阅读