src/share/classes/sun/security/ssl/ClientHandshaker.java

Print this page
rev 928 : Summary: Added support for Server Name Indication (SNI) hello
extension to SSL client.
Contributed-by: Michael Tandy <michaeltandy at googlemail dot com>

@@ -416,11 +416,12 @@
 
         // check extensions
         for (HelloExtension ext : mesg.extensions.list()) {
             ExtensionType type = ext.type;
             if ((type != ExtensionType.EXT_ELLIPTIC_CURVES)
-                    && (type != ExtensionType.EXT_EC_POINT_FORMATS)) {
+                    && (type != ExtensionType.EXT_EC_POINT_FORMATS)
+                    && (type != ExtensionType.EXT_SERVER_NAME)) {
                 fatalSE(Alerts.alert_unsupported_extension,
                     "Server sent an unsupported extension: " + type);
             }
         }
 

@@ -967,10 +968,11 @@
             if (!enableNewSession) {
                 if (session == null) {
                     throw new SSLException(
                         "Can't reuse existing SSL client session");
                 }
+                mesg.setServerName(this.getHostSE());
                 mesg.setCipherSuites(new CipherSuiteList(sessionSuite));
                 return mesg;
             }
         }
         if (session == null) {

@@ -979,10 +981,13 @@
             } else {
                 throw new SSLException("No existing session to resume.");
             }
         }
 
+        // Put an RFC4366 TLS server name indication extension into ClientHello.
+        mesg.setServerName(this.getHostSE());
+
         //
         // All we have left to do is fill out the cipher suites.
         // (If this changes, change the 'return' above!)
         //
         mesg.setCipherSuites(enabledCipherSuites);