如何在JDK 1.7.x中的SSL握手(SNI)中设置主机名

Jan*_*thy 6 java ssl sni

JDK 1.8似乎提供以下选项来显式设置Hostname以连接到启用SNI的站点,

    SNIHostName serverName = new SNIHostName("www.example.com");
    List<SNIServerName> serverNames = new ArrayList<>(1);
    serverNames.add(serverName);
    sslParameters.setServerNames(serverNames);
Run Code Online (Sandbox Code Playgroud)

在JDK 1.7中是否有类似的方法.我已经设置了jsse.enableSNIExtension = true.我需要明确设置主机名.任何帮助深表感谢.

小智 1

Java 7 中无法设置 SNIHostName。我们只能使用 Java 8 进行设置。

您可以参考以下网址了解更多详情。 http://javabreaks.blogspot.com/2015/12/java-ssl-handshake-with-server-name.html