This site is an archive and is no longer updated.
    Back to Chain Builder Tool
    TroubleshootingInfrastructure

    Certificate Chain Building: Complete Guide

    Master certificate chain construction, fix missing intermediates, and resolve common chain validation errors.

    12 min readDecember 2025Troubleshooting Guide
    LinkedInX
    Certificate chain building and troubleshooting guide

    Watch: Certificate Chain Builder Explained

    What is a Certificate Chain?

    A certificate chain (also called a chain of trust) is a sequence of certificates that links your server's certificate to a trusted root CA. Browsers and clients need this chain to verify that your certificate is legitimate.

    Why Chains Matter

    • • Root CAs are kept offline for security - they don't sign server certs directly
    • • Intermediate CAs bridge the gap between roots and leaf certificates
    • • Browsers have ~150+ trusted roots pre-installed, but no intermediates
    • • Your server must provide the intermediate(s) for validation to work

    Anatomy of a Chain

    A typical certificate chain has 2-4 certificates, ordered from leaf to root:

    Leaf Certificate
    www.example.com
    Your server's certificate
    signed by
    Intermediate CA
    DigiCert TLS RSA SHA256
    Bridges leaf to root
    signed by
    Root CA
    DigiCert Global Root CA
    Pre-installed in browsers

    Leaf Certificate

    • • Your actual server certificate
    • • Contains your domain name
    • • Has the shortest validity period
    • • Not a CA (can't sign other certs)

    Intermediate CA

    • • Issued by the root CA
    • • Signs leaf certificates
    • • Must be sent by your server
    • • May have multiple levels

    Root CA

    • • Self-signed (trusts itself)
    • • Pre-installed in browsers/OS
    • • Don't include on your server
    • • Ultimate trust anchor

    Common Chain Problems

    Certificate chain errors are among the most common SSL issues. Here's a quick reference for diagnosing and fixing them:

    Error MessageCauseFix
    unable to get local issuer certificateMissing intermediateAdd intermediate to chain file
    certificate verify failed (depth=1)Wrong intermediateReplace with correct intermediate
    self signed certificate in chainRoot CA includedRemove root from server chain
    PKIX path building failedJava truststore issueImport intermediate to truststore

    Missing Intermediate Certificates

    The most common chain error is a missing intermediate. This happens because your CA gives you a leaf certificate, but you need to download the intermediate separately.

    How to Find Missing Intermediates

    1. Check the AIA Extension

    Most certificates include an Authority Information Access (AIA) URL pointing to the intermediate:

    openssl x509 -in server.crt -noout -text | grep -A1 "Authority Information Access"
    
    # Output:
    # CA Issuers - URI:http://cacerts.digicert.com/DigiCertTLSRSASHA2562020CA1-1.crt

    2. Download from CA Website

    All major CAs publish their intermediate certificates. Search for "[CA name] intermediate certificate download" or check their repository.

    3. Use whatsmychaincert.com

    Paste your certificate and it will automatically find and generate your complete chain file.

    Wrong Certificate Order

    Certificates in your chain file must be in the correct order: leaf first, then intermediates, optionally ending with the root.

    Wrong Order

    1. Intermediate CA
    2. Leaf Certificate
    3. Root CA

    Correct Order

    1. Leaf Certificate
    2. Intermediate CA
    3. (Root CA - optional)

    Pro Tip: Should You Include the Root?

    Generally, don't include the root CA in your server chain. Clients already have it in their trust store, so sending it wastes bandwidth and can cause "self signed certificate in chain" warnings in some tools.

    Server Configuration

    How you configure the chain depends on your server. Here are the most common setups:

    Nginx

    Nginx uses a single file containing the full chain (leaf + intermediates):

    # Create fullchain.pem by concatenating:
    cat server.crt intermediate.crt > fullchain.pem
    
    # nginx.conf
    ssl_certificate     /etc/ssl/certs/fullchain.pem;
    ssl_certificate_key /etc/ssl/private/server.key;

    Apache

    Apache can use separate files or a combined chain:

    # Option 1: Separate files
    SSLCertificateFile      /etc/ssl/certs/server.crt
    SSLCertificateKeyFile   /etc/ssl/private/server.key
    SSLCertificateChainFile /etc/ssl/certs/intermediate.crt
    
    # Option 2: Combined file (Apache 2.4.8+)
    SSLCertificateFile    /etc/ssl/certs/fullchain.pem
    SSLCertificateKeyFile /etc/ssl/private/server.key

    Java / Tomcat

    Java uses a KeyStore. Import the chain with keytool:

    # Import intermediate first
    keytool -import -trustcacerts -alias intermediate \
      -file intermediate.crt -keystore keystore.jks
    
    # Then import your certificate (reply to "Trust this certificate?" with yes)
    keytool -import -trustcacerts -alias server \
      -file server.crt -keystore keystore.jks

    Debugging Chain Issues

    Use these commands to diagnose certificate chain problems:

    Test Remote Server Chain

    openssl s_client -connect example.com:443 -showcerts 2>/dev/null | \
      grep -E "^(Certificate chain| [0-9]+ s:|   i:)"

    Verify Chain Locally

    # Verify your certificate against the chain
    openssl verify -CAfile intermediate.crt server.crt
    
    # Expected output: server.crt: OK

    Check Who Signed Your Certificate

    # Show issuer of your certificate
    openssl x509 -in server.crt -noout -issuer
    
    # Show subject of intermediate (should match above)
    openssl x509 -in intermediate.crt -noout -subject

    Frequently Asked Questions

    Why does my certificate work in Chrome but not Java?

    Chrome can often fetch missing intermediates automatically using the AIA extension. Java does not do this - it requires the complete chain to be provided. Always configure your server with the full chain.

    How many intermediates should I include?

    Include all intermediates between your leaf and a root CA that clients trust. This is typically 1-2 certificates. Your CA should provide them when you download your certificate.

    My chain file has extra whitespace - does it matter?

    Most servers handle whitespace gracefully, but it's best to have each certificate start immediately after the previous one's "-----END CERTIFICATE-----" line, with a single newline between them.

    Ready to Fix Your Chain?

    Use our Chain Builder tool to analyze your certificates and automatically fix order issues.

    Open Chain Builder

    Related Resources