1

I used this Java code from here and when I try to download a file with Google Disk shared link with https I get an error:

javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

As I understand, I have to set in the code:

System.setProperty("javax.net.ssl.trustStore","/usr/lib/jvm/default-java/lib/security/cacerts");

Where in the code I have to put it and what if I run it on Windows PC later?

Hrvoje T
  • 3,365
  • 4
  • 28
  • 41

2 Answers2

1

Ok, the solution for me on Ubuntu 18.04 was this commnet from @jsn on this SO question:

I ran sudo rm /etc/ssl/certs/java/cacerts and then sudo update-ca-certificates -f and this fixed my issue in kubuntu 18.04.

Hrvoje T
  • 3,365
  • 4
  • 28
  • 41
0

Note that if you use Tomcat you should add trustStore properties to setenv.sh.

On Ubuntu/Debian:

-Djavax.net.ssl.trustStorePassword=changeit
-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts

On CentOS/RH the path is different:

-Djavax.net.ssl.trustStore=/etc/pki/ca-trust/extracted/java/cacerts

Note that cacerts keystore is not generated by default on Ubuntu. You need to install ca-certificates-java

apt-get update
apt-get install ca-certificates-java

Note that above will install some Java (JDK 11 on Ubuntu 20). So to keep your previous version you might need change your java path in /etc/alternatives (the file /etc/alternatives/java is a link).

Nux
  • 9,276
  • 5
  • 59
  • 72