-
Notifications
You must be signed in to change notification settings - Fork 2.6k
No such method error setEndpointIdentificationAlgorithm
Marcel Prestel edited this page May 10, 2020
·
1 revision
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.
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)
If you want to target Android API lower 24, you should do the following:
- Override
protected void onSetSSLParameters(SSLParameters sslParameters)
to not callsetEndpointIdentificationAlgorithm()
- Perform the hostname validation after you connected to the server (check out this example code)