javax.net.ssl.SSLException: Received fatal alert: protocol_version when using java-algorand-sdk with PureStake API - Algorand
javax.net.ssl.SSLException: Received fatal alert: protocol_version when using java-algorand-sdk with PureStake API
post by hbquikcomjamesl on Feb 2, 2022
This is in relation to doing https://github.com/algorandfoundation/buildweb3 in Java
This is odd:
Looking at the PureStake sample code, and with a PureStake account set up, and after trying some things in their Swagger Playground, I tried simply plugging in appropriate PureStake values on a copy of the GettingStarted class from the Java “Your First Transaction” demo:
private AlgodClient connectToNetwork() {
final String ALGOD_API_ADDR = "https://testnet-algorand.api.purestake.io/ps2";
final String ALGOD_API_TOKEN = <REDACTED>;
final String ALGOD_API_TOKEN_KEY = "X-API-Key";
final Integer ALGOD_PORT = 443;
. . .
It sat there for quite a few seconds, and then I got this:
Exception in thread "main" javax.net.ssl.SSLException: Received fatal alert: protocol_version
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
...
Clearly, something is not on speaking terms . . . .
post by fabrice on Feb 2, 2022
Your Java version looks too old and does not support the TLS version of PureStake.
PureStake only supports TLS 1.2 and 1.3 (which is now industry standard as previous versions are essentially insecure).
Which version of Java are you using?
You definitely need at the very least Java 1.8.
If you’re using Maven, set the Java version using https://www.baeldung.com/maven-java-version
post by hbquikcomjamesl on Feb 2, 2022
From a command line, I get:
Jamess-iMac:~ jameslampert$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
... (continued discussion about Java versions and details)
post by fabrice on Feb 3, 2022
This is the issue.
Java 1.7 will not work with PureStake.
If you’re using maven see comment above.
Otherwise, see Java project management in Visual Studio Code
post by hbquikcomjamesl on Feb 3, 2022
Yes. I gathered that the problem was that VS Code was using Java 7, even though Java 8 is not only installed, but is the default Java. Thanks for the link: I’ve got it open in the next browser tab, and hopefully it will solve the problem. VS Code is as new to me as Algorand is.
That solved the problem. And I’d completely forgotten that the project does use Maven ...
Thanks once again for your patience.