TakahikoKawasaki / nv-websocket-client

High-quality WebSocket client implementation in Java.
Apache License 2.0
2.03k stars 292 forks source link

Very misleading error message if jdk.crypto.ec module is missing #234

Open Vampire opened 2 years ago

Vampire commented 2 years ago

If you have a runtime image without module jdk.crypto.ec but try to connect to a service that needs it like Discord, this library complains that the hostname does not match which is plainly wrong and very misleading:

$ rm -rf jre
$ ~/.gradle/jdks/jdk-17+35/bin/jlink --add-modules jdk.jshell,jdk.zipfs --output jre
$ jre/bin/jshell.exe -c nv-websocket-client-2.6.jar
|  Welcome to JShell -- Version 17
|  For an introduction type: /help intro

jshell> new com.neovisionaries.ws.client.WebSocketFactory().createSocket("wss://gateway.discord.gg").connect()
|  Exception com.neovisionaries.ws.client.HostnameUnverifiedException: The certificate of the peer does not match the expected hostname (gateway.discord.gg)
|        at SocketConnector.verifyHostname (SocketConnector.java:171)
|        at SocketConnector.doConnect (SocketConnector.java:126)
|        at SocketConnector.connect (SocketConnector.java:83)
|        at WebSocket.connect (WebSocket.java:2307)
|        at (#1:1)

jshell>
$ rm -rf jre
$ ~/.gradle/jdks/jdk-17+35/bin/jlink --add-modules jdk.jshell,jdk.zipfs,jdk.crypto.ec --output jre
$ jre/bin/jshell.exe -c nv-websocket-client-2.6.jar
|  Welcome to JShell -- Version 17
|  For an introduction type: /help intro

jshell> new com.neovisionaries.ws.client.WebSocketFactory().createSocket("wss://gateway.discord.gg").connect()
$1 ==> com.neovisionaries.ws.client.WebSocket@6f4a47c7

jshell>