SSOGEN / Free tools / PKIX path building failed: unable to find valid certification path

SSOGEN

PKIX path building failed: unable to find valid certification path

Unable to find valid certification path to requested target means Java could not link the server's certificate to any root in its truststore. Paste the server's chain below to see which CA is missing and the keytool command that adds it. The check runs in your browser.

Exploded stack of three certificate plates: the middle plate is missing, the bottom one sits in the truststore tray
Java needs every link from the server's certificate down to a trust anchor in its truststore.

Paste the chain, find the missing CA

The output of openssl s_client -showcerts, or one or more PEM blocks (-----BEGIN CERTIFICATE-----). A sample chain for acme.example is loaded; replace it with yours.

Private by design. The check runs in this page and nothing is uploaded. Certificates hold only public information; never paste a private key into any web page (this tool refuses it).

To get the chain, run this against the server that fails:

openssl s_client -connect app.acme.example:443 -servername app.acme.example -showcerts

The OpenSSL manual says -showcerts lists the certificates exactly as the server sent them, in the order sent, and that the list is not a verified chain. Paste the whole output, or the PEM blocks alone. To read a single certificate in detail, use the certificate decoder.

The checker draws the chain from leaf to root and marks each certificate as sent, linked or missing. For the certificate that needs trust, it shows the subject, the SHA-256 fingerprint and the validity dates, and it prints the keytool command for your JDK. It cannot see your truststore, so the result reads “import this if your JDK does not already trust it”. The keytool -list check below settles that.

What this error means

Java’s PKIX validator could not build a path from the server’s certificate to a trust anchor, which is a certificate in the truststore. The certificate is often valid. The truststore lacks the CA that issued it, or the server did not send its intermediate.

The full line is two messages joined. In the OpenJDK source (tag jdk-21-ga), PKIXValidator puts “PKIX path building failed: “ in front of the text of the underlying exception, and SunCertPathBuilder supplies that text:

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

The message names no certificate. That is why you inspect the chain the server sends.

Four chain problems behind it

Cause How to tell Fix
A private or internal CA The chain ends in a self-signed root issued by your company or a vendor Import that root into the truststore Java reads
An incomplete chain The last certificate sent is not self-signed, and its issuer is not in the paste Configure the server to send its intermediate. Android’s documentation names the same cause
A self-signed server certificate One certificate, with the same subject and issuer Import it as a stopgap, then replace it with a CA-issued certificate
A different truststore The CA is trusted by some JDK, but the failing process reads another file, for example one set with -Djavax.net.ssl.trustStore Import into the file that process reads

The checker also reports expired certificates and links that fail the signature check. Those need a change on the server, not an import. For handshake failures that are not about trust, such as protocol, SNI and name mismatches, see javax.net.ssl.SSLHandshakeException.

Import the missing CA with keytool

  1. Save the CA certificate

    Copy the PEM block the checker names into a file, for example acme-root-ca.pem.

  2. Check the fingerprint

    Run keytool -printcert -file acme-root-ca.pem and compare the fingerprint with the value from the CA or your PKI team. Import only when they match.

  3. See whether Java already trusts it

    Run keytool -list -cacerts (JDK 9 and later). It prints the SHA-256 fingerprint of every entry, so search the output for the fingerprint from step 2.

  4. Import it

    Run the command for your setup. Enter the store password when keytool asks. The documented initial password of cacerts is changeit, and the keytool manual advises changing it.

  5. Verify and retry

    Run keytool -list -cacerts -alias acme-root-ca, then restart the Java process and repeat the request that failed.

JDK 9 and later: the -cacerts option
keytool -importcert -cacerts -alias acme-root-ca -file acme-root-ca.pem
JDK 8: name the file (java.home is the jre directory of a JDK)
keytool -importcert -keystore "$JAVA_HOME/jre/lib/security/cacerts" -alias acme-root-ca -file acme-root-ca.pem
Your own truststore file
keytool -importcert -storetype PKCS12 -keystore acme-truststore.p12 -alias acme-root-ca -file acme-root-ca.pem
java -Djavax.net.ssl.trustStore=acme-truststore.p12 -Djavax.net.ssl.trustStoreType=PKCS12 -jar app.jar

The -cacerts option takes no path, so the command is the same on Linux, macOS and Windows. When javax.net.ssl.trustStore is set, Java uses that file. Only when it is not set does Java look for jssecacerts and then cacerts in the Java home. Where each store lives and how they differ is covered in Java cacerts and truststore. Other keytool commands are built by the keytool command generator.

What not to do

Your own app and SSOGEN

  • Java agent. When the JVM does not trust the CA that issued SSOGEN’s certificate, set caCertificateFile to a readable PEM file with that CA’s certificate. The default is the JVM’s trust store. See the Java agent.
  • SSOGEN to your directory. SSOGEN trusts the public certificate authorities by default. A Super admin or Authentication admin adds an internal CA under Settings, Certificates. See trusted certificates.

Questions people ask

How to fix pkix error?

Add the missing CA to the truststore Java reads, or make the server send its full chain. Paste the chain into the checker above to see which applies. Import the CA with keytool -importcert after checking its fingerprint, then confirm it with keytool -list. Never disable certificate validation as a shortcut.

Why does it say my certificate is invalid?

Usually the certificate is not invalid. Java cannot link it to a root it trusts. The root may be private, the server may have left out an intermediate, or the process may read a different truststore. An expired certificate is a separate fault, which the checker reports from the dates in the paste.

How to solve trust anchor for certification path not found on Android?

Android reports the same cause: the chain does not end in a CA the device trusts. Its documentation lists three reasons: an unrecognized CA, a self-signed server certificate, or a server missing an intermediate CA. For a private CA, change the app’s Network Security Config instead of using a TrustManager that accepts everything.

How do I fix this error on a Mac?

Use the same keytool command as on Linux and Windows. The -cacerts option takes no path, so run keytool -importcert -cacerts -alias acme-root-ca -file acme-root-ca.pem against the JDK your app runs on, then verify with keytool -list -cacerts. On JDK 8, name the cacerts file with -keystore, as shown above.

Sources

Sources, all read 2026-11-17: