Based on the JSSE examples, I'm trying to get the value of the TLS parameter "Server Name Indication" (SNI) on the server side - without success. I'm sure that the value is sent by the client since I used a network sniffer (Wireshark) that shows the value.
But when I use the following code fragment, the list of server name parameters is empty (while the "protocols" are shown):
public void connectionAccepted(Socket socket)
{
System.out.println("Connection accepted!");
try {
/* get SNI parameter */
SSLSocket sslSocket = (SSLSocket)socket;
SSLParameters sslParams = sslSocket.getSSLParameters();
List<SNIServerName> serverNames = sslParams.getServerNames();
for(SNIServerName item : serverNames){
System.out.println("SNI: " + item.toString());
}
String[] protocols = sslParams.getProtocols();
for(String item : protocols) {
System.out.println("Protocols: " + item.toString());
}
} catch (Exception e) {
e.printStackTrace();
}
}