@@ -200,22 +200,9 @@ public void negotiateSSLConnection(int packLength) {
200
200
// the message reader is async and is always "reading". we need to stop it to use the socket for the TLS handshake
201
201
this .reader .stopAfterNextMessage ();
202
202
203
- this .clientCapabilities .put (XServerCapabilities .KEY_TLS , true );
204
-
205
- try {
206
- sendCapabilities (this .clientCapabilities );
207
- } catch (XProtocolError e ) {
208
- // XProtocolError: ERROR 5002 (HY000) Capability 'session_connect_attrs' doesn't exist
209
- // happens when connecting to xplugin which doesn't support this feature.
210
- // Just ignore this error and retry with reduced clientCapabilities
211
- if (e .getErrorCode () != 5002 && !e .getMessage ().contains (XServerCapabilities .KEY_SESSION_CONNECT_ATTRS )) {
212
- throw e ;
213
- }
214
- this .clientCapabilities .remove (XServerCapabilities .KEY_SESSION_CONNECT_ATTRS );
215
- this .reader .start ();
216
- this .reader .stopAfterNextMessage ();
217
- sendCapabilities (this .clientCapabilities );
218
- }
203
+ Map <String , Object > tlsCapabilities = new HashMap <>();
204
+ tlsCapabilities .put (XServerCapabilities .KEY_TLS , true );
205
+ sendCapabilities (tlsCapabilities );
219
206
220
207
try {
221
208
this .socketConnection .performTlsHandshake (null ); //(this.serverSession);
@@ -304,9 +291,7 @@ public void beforeHandshake() {
304
291
throw new CJCommunicationsException (msg .toString ());
305
292
}
306
293
307
- if (xdevapiSslMode .getValue () != XdevapiSslMode .DISABLED ) {
308
- negotiateSSLConnection (0 );
309
- } else if (this .clientCapabilities .size () > 0 ) {
294
+ if (this .clientCapabilities .size () > 0 ) {
310
295
try {
311
296
sendCapabilities (this .clientCapabilities );
312
297
} catch (XProtocolError e ) {
@@ -318,6 +303,10 @@ public void beforeHandshake() {
318
303
this .clientCapabilities .remove (XServerCapabilities .KEY_SESSION_CONNECT_ATTRS );
319
304
}
320
305
}
306
+
307
+ if (xdevapiSslMode .getValue () != XdevapiSslMode .DISABLED ) {
308
+ negotiateSSLConnection (0 );
309
+ }
321
310
}
322
311
323
312
private Map <String , String > getConnectionAttributesMap (String attStr ) {
@@ -710,7 +699,9 @@ public void reset() {
710
699
Map <String , Object > reducedClientCapabilities = new HashMap <>();
711
700
reducedClientCapabilities .put (XServerCapabilities .KEY_SESSION_CONNECT_ATTRS ,
712
701
this .clientCapabilities .get (XServerCapabilities .KEY_SESSION_CONNECT_ATTRS ));
713
- sendCapabilities (reducedClientCapabilities );
702
+ if (reducedClientCapabilities .size () > 0 ) {
703
+ sendCapabilities (reducedClientCapabilities );
704
+ }
714
705
}
715
706
716
707
this .authProvider .changeUser (null , this .currUser , this .currPassword , this .currDatabase );
0 commit comments