I'm trying to configure my e-mail on Jenkins/Hudson, and I constantly receive the error:
java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be
non-empty
I've seen a good amount of information online about the error, but I have not gotten any to work. I'm using Sun's JDK on Fedora Linux (not OpenJDK).
Here are a few things I've tried. I tried following the advice from this post, but copying the cacerts from Windows over to my Fedora box hosting Jenkins didn't work. I tried following this guide as I'm trying to configure Gmail as my SMTP server, but it didn't work either. I also tried to download and move those cacert files manually and move them over to my Java folder using a variation of the commands on this guide.
I am open to any suggestions as I'm currently stuck right now. I have gotten it to work from a Windows Hudson server, but I am struggling on Linux.
In Ubuntu 12.10 (Quantal Quetzal) or later, the certificates are held in the ca-certificates-java package. Using
-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts
will pick them up regardless of what JDK you're using.I also encountered this on OS X after updating OS X v10.9 (Mavericks), when the old Java 6 was being used and tried to access an HTTPS URL. The fix was the inverse of Peter Kriens; I needed to copy the
cacerts
from the 1.7 space to the location linked by the 1.6 version:In windows10 and openjdk was caused by having an empty cacerts file distributed with the binary. The bug is explained here: https://github.com/AdoptOpenJDK/openjdk-build/issues/555
You can copy to
adoptOpenJdk8\jre\lib\security\cacerts
the file from an old instalation likec:\Program Files\Java\jdk1.8.0_192\jre\lib\security\cacerts
.The AdoptOpenJDK buggy version is https://github.com/AdoptOpenJDK/openjdk8-releases/releases/download/jdk8u172-b11/OpenJDK8_x64_Win_jdk8u172-b11.zip
In Ubuntu 18.04, this error has a different cause (JEP 229, switch from the
jks
keystore default format to thepkcs12
format, and the Debian cacerts file generation using the default for new files) and workaround:https://git.mikael.io/mikaelhg/broken-docker-jdk9-cacerts
Status (2018-08-07), the bug has been fixed in Ubuntu Bionic LTS 18.04.1 and Ubuntu Cosmic 18.10.
For me it was caused by the lack of a trustedCertEntry in the truststore.
To test, use:
It gives me:
Even though my PrivateKeyEntry contains a CA it needed to be imported separately:
It imports the certificate, and then re-running
keytool -list -keystore keystore.jks
now gives:Now it has a trustedCertEntry, and Tomcat will start successfully.
I ran into this solution from blog post Fixing the trustAnchors problem when running OpenJDK 7 on OS X:
Fixing the trustAnchors problem when running OpenJDK 7 on OS X. If you're running OpenJDK 7 on OS X and have seen this exception:
There's a simple fix. Just link in the same cacerts file that Apple’s JDK 1.6 uses:
You need to do this for every OpenJDK version you have installed. Just change
-v 1.7
to the version you want to fix. Run/usr/libexec/java_home -V
to see all the JREs and JDKs you have installed.Perhaps the OpenJDK guys could add this to their install scripts.