When you google for this exception: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
, multiple results appear. However there is no definitive solution, only guesses.
The problem arises (in my case at least) when I try to use open a connection over SSL. It works fine on my windows machine, but when I deploy it to the linux machine (with sun's jre installed) it fails with the above exception.
The problem is that the default truststore of the JRE is empty for some reason (size of only 32 bytes, whereas it is 80kb on windows).
When I copied my jre/lib/security/cacerts
file from windows to linux, it worked fine.
The question is - why is the linux jre having an empty trust store?
Note that this happens on an Amazon EC2 instance, with the AMI linux, so it might be due to some amazon policies (I think java was pre-installed, but I'm not sure)
I got this error in Ubuntu. I saw that /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts was a broken link to /etc/ssl/certs/java/cacerts. That lead me to this bug: https://bugs.launchpad.net/ubuntu/+source/ca-certificates-java/+bug/983302 The README for ca-certificates-java eventually showed the actual fix:
run
update-ca-certificates -f
apt-get install ca-certificates-java didn't work for me. It just marked it as manually installed.
The standard Sun JDK for linux has an absolutely ok cacerts and overall all files in the specified directory. The problem is the installation you use.
I have avoided this error (Java 1.6.0 on OSX 10.5.8) by putting a dummy cert in the keystore, such as
keytool -genkey -alias foo -keystore cacerts -dname cn=test -storepass changeit -keypass changeit
Surely the question should be "Why can't java handle an empty trustStore?"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With