Skip to content
ecdsa.com
Java (JSSE / PKIX)Java

Error message

java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

Also printed as

  • javax.net.ssl.SSLException: (internal_error) Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
  • the trustAnchors parameter must be non-empty

JDK 25 reports it as "javax.net.ssl.SSLException: (internal_error) Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty", with "java.lang.RuntimeException: Unexpected error: …" in the cause chain. A trust store path that does not exist at all gives "PKIX path building failed" instead.

Java (JSSE / PKIX) — the trust store the JVM loaded contains no trusted certificates

What it means

The JVM loaded a trust store that contains no trusted certificate entries, so the PKIX validator has no trust anchors at all and refuses to start. It happens before any certificate is checked: the file exists and opens, but it is empty for TLS trust purposes. Every HTTPS connection of the process fails the same way.

Why it happens

How to fix it

  1. 1.

    Count the trusted entries

    keytool -list shows the entries; a trust store needs trustedCertEntry lines. Compare with the JDK's default store.

    bash
    # How many trusted certificates does the store hold? (0 reproduces this error)
    keytool -list -keystore "$TRUSTSTORE" -storepass "$TRUSTSTORE_PASSWORD" | grep -c trustedCertEntry
    keytool -list -cacerts -storepass changeit | grep -c trustedCertEntry    # the JDK's default store
  2. 2.

    Restore the JDK's default trust store

    On Debian and Ubuntu, reinstalling ca-certificates-java regenerates /etc/ssl/certs/java/cacerts; on Alpine the java-cacerts package provides it.

    bash
    # Debian/Ubuntu OpenJDK packages build cacerts from the system CA bundle
    sudo apt-get install --reinstall ca-certificates-java
    sudo update-ca-certificates -f
    # Alpine
    apk add --no-cache java-cacerts
  3. 3.

    Keep key store and trust store separate

    Pass your own certificate and key as javax.net.ssl.keyStore and the CA certificates as javax.net.ssl.trustStore.

    bash
    # Key store (your key + certificate) and trust store (CAs you trust) are different files
    java -Djavax.net.ssl.keyStore=client.p12   -Djavax.net.ssl.keyStorePassword=changeit \
         -Djavax.net.ssl.trustStore=truststore.p12 -Djavax.net.ssl.trustStorePassword=changeit -jar app.jar

Related errors

Browse the full signature error database