File tree Expand file tree Collapse file tree
org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal
org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,26 +136,25 @@ public void start() throws IOException, MqttException {
136136 socket .setSoTimeout (this .handshakeTimeoutSecs * 1000 );
137137
138138 // SNI support. Should be automatic under some circumstances - not all, apparently
139+ SSLParameters sslParameters = ((SSLSocket )socket ).getSSLParameters ();
139140 try {
140- SSLParameters sslParameters = new SSLParameters ();
141141 List <SNIServerName > sniHostNames = new ArrayList <SNIServerName >(1 );
142142 sniHostNames .add (new SNIHostName (host ));
143143 sslParameters .setServerNames (sniHostNames );
144- ((SSLSocket )socket ).setSSLParameters (sslParameters );
145144 } catch (NoClassDefFoundError e ) {
146145 // Android < 7.0
147146 }
148147
149148 // If default Hostname verification is enabled, use the same method that is used with HTTPS
150149 if (this .httpsHostnameVerificationEnabled ) {
151150 try {
152- SSLParameters sslParams = new SSLParameters ();
153- sslParams .setEndpointIdentificationAlgorithm ("HTTPS" );
154- ((SSLSocket ) socket ).setSSLParameters (sslParams );
151+ sslParameters .setEndpointIdentificationAlgorithm ("HTTPS" );
155152 } catch (NoSuchMethodError e ) {
156153 // Android < 7.0
157154 }
158155 }
156+ ((SSLSocket )socket ).setSSLParameters (sslParameters );
157+
159158 ((SSLSocket ) socket ).startHandshake ();
160159 if (hostnameVerifier != null && !this .httpsHostnameVerificationEnabled ) {
161160 SSLSession session = ((SSLSocket ) socket ).getSession ();
Original file line number Diff line number Diff line change @@ -130,19 +130,18 @@ public void start() throws IOException, MqttException {
130130 socket .setSoTimeout (this .handshakeTimeoutSecs * 1000 );
131131
132132 // SNI support. Should be automatic under some circumstances - not all, apparently
133- SSLParameters sslParameters = new SSLParameters ();
133+ SSLParameters sslParameters = (( SSLSocket ) socket ). getSSLParameters ();
134134 List <SNIServerName > sniHostNames = new ArrayList <SNIServerName >(1 );
135135 sniHostNames .add (new SNIHostName (host ));
136136 sslParameters .setServerNames (sniHostNames );
137- ((SSLSocket )socket ).setSSLParameters (sslParameters );
138137
139138 // If default Hostname verification is enabled, use the same method that is used with HTTPS
140139 if (this .httpsHostnameVerificationEnabled ) {
141- SSLParameters sslParams = new SSLParameters ();
142- sslParams .setEndpointIdentificationAlgorithm ("HTTPS" );
143- ((SSLSocket ) socket ).setSSLParameters (sslParams );
140+ sslParameters .setEndpointIdentificationAlgorithm ("HTTPS" );
144141 }
145142
143+ ((SSLSocket ) socket ).setSSLParameters (sslParameters );
144+
146145 ((SSLSocket ) socket ).startHandshake ();
147146 if (hostnameVerifier != null ) {
148147 SSLSession session = ((SSLSocket ) socket ).getSession ();
You can’t perform that action at this time.
0 commit comments