You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No such method error setEndpointIdentificationAlgorithm
Marcel Prestel edited this page May 10, 2020
·
1 revision
Introduction
Even though Android is not our main focus, we still try to be as compatible as possible with our Android user base.
For our release 1.5.0 we had to update to Java API Version 1.7.
Problem
Starting with release 1.5.0 we are using the method SSLParameters.setEndpointIdentificationAlgorithm to improve security and perform hostname validation out of the box.
This API was introduced to Android with API level 24.
If you are using this library with a lower API Level you will run into the following exception:
Fatal Exception: java.lang.NoSuchMethodError: No virtual method setEndpointIdentificationAlgorithm(Ljava/lang/String;)V in class Ljavax/net/ssl/SSLParameters; or its super classes (declaration of 'javax.net.ssl.SSLParameters' appears in /system/framework/core-libart.jar)
at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:476)
at java.lang.Thread.run(Thread.java:831)
Workaround
If you want to target Android API lower 24, you should do the following:
Override protected void onSetSSLParameters(SSLParameters sslParameters) to not call setEndpointIdentificationAlgorithm()
Perform the hostname validation after you connected to the server (check out this example code)