问题
As per Wikipedia, Java 1.7 should support SNIServerName, but as per Java docs there is no such class in their javax.net.ssl package.Can someone please clarify this? Will I have to use Java 8 API to use SNIServerName class?
回答1:
The support is there, see https://docs.oracle.com/javase/7/docs/technotes/guides/security/enhancements-7.html:
Server Name Indication (SNI) for JSSE client: The Java SE 7 release supports the Server Name Indication (SNI) extension in the JSSE client. SNI is described in RFC 4366. This enables TLS clients to connect to virtual servers.
However, it is implemented in a different way. For example https://issues.apache.org/jira/browse/HTTPCLIENT-1119 discusses this. The relevant quote might be
Java 8 has a completely different SNI API provided out of javax.net.ssl package
So yes, you won't have that class with Java 7, and you will "have to use Java 8 API to use SNIServerName class", like you asked.
For discussion on how to use SNI with Java 7, see this thread.
来源:https://stackoverflow.com/questions/41829133/java-sniservername-support-in-java-7