File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
main/java/org/java_websocket/client
test/java/org/java_websocket/issues Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -472,8 +472,6 @@ public void run() {
472472 if (socket instanceof SSLSocket ) {
473473 SSLSocket sslSocket = (SSLSocket )socket ;
474474 SSLParameters sslParameters = sslSocket .getSSLParameters ();
475- // Make sure we perform hostname validation
476- sslParameters .setEndpointIdentificationAlgorithm ("HTTPS" );
477475 onSetSSLParameters (sslParameters );
478476 sslSocket .setSSLParameters (sslParameters );
479477 }
@@ -520,10 +518,14 @@ public void run() {
520518
521519 /**
522520 * Apply specific SSLParameters
521+ * If you override this method make sure to always call super.onSetSSLParameters() to ensure the hostname validation is active
523522 *
524523 * @param sslParameters the SSLParameters which will be used for the SSLSocket
525524 */
526525 protected void onSetSSLParameters (SSLParameters sslParameters ) {
526+ // If you run into problem on Android (NoSuchMethodException), check out the wiki https://github.com/TooTallNate/Java-WebSocket/wiki/No-such-method-error-setEndpointIdentificationAlgorithm
527+ // Perform hostname validation
528+ sslParameters .setEndpointIdentificationAlgorithm ("HTTPS" );
527529 }
528530
529531 /**
Original file line number Diff line number Diff line change @@ -143,6 +143,8 @@ public void onError(Exception ex) {
143143
144144 @ Override
145145 protected void onSetSSLParameters (SSLParameters sslParameters ) {
146+ // Always call super to ensure hostname validation is active by default
147+ super .onSetSSLParameters (sslParameters );
146148 if (endpointIdentificationAlgorithm != null ) {
147149 sslParameters .setEndpointIdentificationAlgorithm (endpointIdentificationAlgorithm );
148150 }
You can’t perform that action at this time.
0 commit comments