Trust an internal CA for outbound HTTPS connections

For the complete documentation index, see llms.txt. For a full content snapshot, see llms-full.txt. Append .md to any kestra.io/docs/* URL for plain Markdown.

Add your internal root certificate authority (CA) to the Kestra JVM truststore so tasks can call HTTPS services signed by that CA.

Without it, tasks that connect to those services fail with:

javax.net.ssl.SSLHandshakeException: PKIX path building failed: unable to find valid certification path to requested target

When you need a custom truststore

You need this setup when Kestra connects over HTTPS to an endpoint whose certificate chains to a CA that the JVM doesn’t ship with:

  • Internal services. APIs, artifact registries, or object storage whose certificates are signed by a private or self-signed CA.
  • The Kestra API itself. Tasks in the Kestra plugin call the Kestra API at kestraUrl, which defaults to the kestra.url setting. If kestra.url is served with a certificate from an internal CA, these tasks fail with the same PKIX path building failed error, even though they run inside Kestra. See Kestra plugin tasks for an alternative that avoids the truststore.
  • Your identity provider (Enterprise Edition). The webserver fetches the OpenID Connect discovery document from the issuer URL at startup. If that fetch fails, Kestra still starts, but SSO login returns HTTP 500 with Failed to retrieve OpenID configuration.

The JVM truststore covers outbound connections made by the Kestra JVM. Other TLS settings have their own configuration:

ConnectionConfigured with
Browsers and API clients connecting to Kestra over HTTPSmicronaut.server.ssl. See Configure SSL for Kestra.
Workers connecting to the controller over gRPC (Enterprise Edition)kestra.grpc.tls.trust-store. See Worker Groups transport security.
Commands run by script tasks, such as Python or Shell scriptsA CA bundle passed to the script’s runtime. See Script tasks.
Connections opened by plugins that have their own CA or truststore property, for example AMQP sslCaCertificate, MQTT crt, or the Syslog log exporter’s trustStorePathThe plugin property. When set, it applies only to that connection and is usually used instead of the JVM truststore, so it must contain every CA that connection needs. When unset, the JVM truststore applies.

How the JVM truststore works

The JVM ships with a default truststore, cacerts, that holds the public CAs. Setting -Djavax.net.ssl.trustStore replaces that default; it doesn’t add to it. The truststore you point Kestra at must therefore hold the image’s cacerts plus your internal CA.

Import your internal root CA, not the server certificates it signs. Server certificates are renewed often, and each renewal would break trust; the root CA stays valid for years and covers every certificate it issues.

Prerequisites

  • The root CA certificate in PEM format. The examples use internal-root-ca.pem.
  • Docker, to read cacerts from the Kestra image and run keytool. The Kestra image ships keytool, so you don’t need a local JDK.
  • For Kubernetes: kubectl and helm access to the namespace where Kestra runs.

Build the truststore

Build the truststore from the same Kestra image tag that you deploy. The steps are the same for Docker, Docker Compose, and Kubernetes.

  1. Set the image to the exact tag you run, and place your root CA in a working directory:

    KESTRA_IMAGE=registry.kestra.io/docker/kestra:latest # replace with the tag you deploy
    mkdir -p ssl
    cp /path/to/internal-root-ca.pem ssl/
  2. Copy cacerts out of the image. The file is already in PKCS12 format, so no conversion is needed:

    docker run --rm --entrypoint cat "$KESTRA_IMAGE" \
    /opt/java/openjdk/lib/security/cacerts > ssl/truststore.p12

    On Kubernetes, you can instead copy it from a running pod with kubectl cp $NAMESPACE/$POD_NAME:/opt/java/openjdk/lib/security/cacerts ./ssl/truststore.p12.

  3. Import the root CA with the keytool bundled in the image:

    docker run --rm --user "$(id -u):$(id -g)" -v "$PWD/ssl:/ssl" \
    --entrypoint keytool "$KESTRA_IMAGE" \
    -importcert -noprompt \
    -alias internal-root-ca \
    -file /ssl/internal-root-ca.pem \
    -keystore /ssl/truststore.p12 \
    -storepass changeit

    If you have a JDK installed locally, you can run the same keytool -importcert command directly against ssl/truststore.p12.

  4. Verify the truststore holds both your CA and the public CAs:

    docker run --rm -v "$PWD/ssl:/ssl:ro" --entrypoint keytool "$KESTRA_IMAGE" \
    -list -keystore /ssl/truststore.p12 -storepass changeit | grep -E "contains|internal-root-ca"

    The output lists your alias and a total of more than 100 entries:

    Your keystore contains 118 entries
    internal-root-ca, Nov 24, 2026, trustedCertEntry,

    If the total is 1, you imported into an empty truststore instead of a copy of cacerts. Restart from step 2.

changeit is the default cacerts password. If you change it with keytool -storepasswd, use the new value in every command and in JAVA_OPTS.

Configure Kestra to use the truststore

Mount truststore.p12 into the Kestra container and point the JVM at it with JAVA_OPTS. If you already set JAVA_OPTS, append these flags to the existing value.

Apply the truststore to every Kestra server that makes outbound calls: workers run tasks, and the webserver calls your identity provider. A standalone server covers both. In a distributed deployment, configure each component, including workers that run outside the cluster or on other Docker hosts.

Docker Compose

Add a bind mount and the JAVA_OPTS variable to the Kestra service:

services:
kestra:
image: registry.kestra.io/docker/kestra:latest
volumes:
- ./ssl/truststore.p12:/app/ssl/truststore.p12:ro
# ...your existing volumes
environment:
JAVA_OPTS: >-
-Djavax.net.ssl.trustStore=/app/ssl/truststore.p12
-Djavax.net.ssl.trustStorePassword=changeit
-Djavax.net.ssl.trustStoreType=PKCS12
# ...your existing environment variables

Recreate the container to apply the change:

docker compose up -d kestra

Docker

Add the same mount and variable to your docker run command. For example:

docker run -d --name kestra \
-v "$PWD/ssl/truststore.p12:/app/ssl/truststore.p12:ro" \
-e JAVA_OPTS="-Djavax.net.ssl.trustStore=/app/ssl/truststore.p12 -Djavax.net.ssl.trustStorePassword=changeit -Djavax.net.ssl.trustStoreType=PKCS12" \
-p 8080:8080 \
"$KESTRA_IMAGE" server local

Kubernetes with Helm

  1. Create a Secret from the truststore. The truststore.p12= prefix sets the key name, which becomes the mounted filename:

    kubectl create secret generic kestra-truststore \
    --from-file=truststore.p12=ssl/truststore.p12 \
    -n $NAMESPACE --save-config
  2. Mount the Secret and set JAVA_OPTS in your values.yaml:

    common:
    extraVolumes:
    - name: truststore
    secret:
    secretName: kestra-truststore
    extraVolumeMounts:
    - name: truststore
    mountPath: /app/ssl
    readOnly: true
    extraEnv:
    - name: JAVA_OPTS
    value: >-
    -Djavax.net.ssl.trustStore=/app/ssl/truststore.p12
    -Djavax.net.ssl.trustStorePassword=changeit
    -Djavax.net.ssl.trustStoreType=PKCS12

    Values under common apply to every component the chart deploys, including worker groups.

  3. Apply the values:

    helm upgrade --install $RELEASE_NAME kestra/kestra -n $NAMESPACE -f values.yaml

Verify outbound connections

Run a flow that calls one internal endpoint and one public endpoint. Both tasks must succeed:

id: truststore_check
namespace: company.team
tasks:
- id: internal_endpoint
type: io.kestra.plugin.core.http.Request
uri: https://internal.example.com/
- id: public_endpoint
type: io.kestra.plugin.core.http.Request
uri: https://api.github.com/
  • If internal_endpoint fails with PKIX path building failed, the JVM isn’t using your truststore, or the truststore doesn’t hold the CA that signed the server certificate. Check the value inside the container, for example with docker compose exec kestra sh -c 'echo $JAVA_OPTS', and check the alias with the verification command in Build the truststore.
  • If public_endpoint fails, the truststore holds only your CA. Rebuild it from cacerts. Other features that call public services, such as community blueprints, fail the same way.

Kestra plugin tasks

If TLS is terminated in front of Kestra, by a reverse proxy or an ingress, the webserver itself still serves plain HTTP on port 8080 inside your network. Tasks in the Kestra plugin can call that internal address instead of kestra.url, and then don’t need the truststore. Set the default endpoint for all tasks in your configuration:

kestra:
tasks:
sdk:
authentication:
url: http://kestra:8080 # internal service address
username: admin@example.com
password: "<password>"

The url is used only together with username and password, or api-token. To change a single task, set its kestraUrl property instead. Credentials go over this connection unencrypted, so use it only on a network you trust.

This doesn’t apply when Kestra serves HTTPS itself with micronaut.server.ssl: the plain-HTTP port is then not started. Use the truststore in that case.

Script tasks

Script tasks run their commands in a separate process or container, which doesn’t use the Kestra JVM truststore. Pass a CA bundle to the runtime instead, and build it from the image’s system bundle plus your CA. As with the JVM, some clients replace their default CAs with the file you give them; requests is one of them.

Upload internal-root-ca.pem as a namespace file, then pass it to the task:

id: script_with_internal_ca
namespace: company.team
tasks:
- id: call_internal_api
type: io.kestra.plugin.scripts.python.Script
containerImage: python:3.12-slim
inputFiles:
internal-root-ca.pem: "{{ read('internal-root-ca.pem') }}"
beforeCommands:
- cat /etc/ssl/certs/ca-certificates.crt internal-root-ca.pem > ca-bundle.pem
- pip install requests
env:
SSL_CERT_FILE: ca-bundle.pem
REQUESTS_CA_BUNDLE: ca-bundle.pem
script: |
import requests
print(requests.get("https://internal.example.com/").status_code)
  • Set REQUESTS_CA_BUNDLE for requests and the Kestra Python library, which ignore SSL_CERT_FILE.
  • Create the bundle before any command that downloads packages, such as pip install: the variables apply to beforeCommands too.
  • The system bundle path depends on the image. /etc/ssl/certs/ca-certificates.crt applies to Debian, Ubuntu, and Alpine images.
  • For curl, pass the bundle with --cacert ca-bundle.pem.

Keep the truststore current

The cacerts you copied freezes the JDK’s list of public CAs at the image version you took it from. Kestra images pick up JDK updates, including in patch releases, and JDK updates add new CAs and remove distrusted ones. A truststore mounted from an older image misses the new CAs and keeps trusting removed ones.

Rebuild the truststore:

  • On every Kestra upgrade, including patch releases. Repeat Build the truststore with the new image tag, then replace the mounted file before you start the new version. On Kubernetes, update the Secret before running helm upgrade:

    kubectl create secret generic kestra-truststore \
    --from-file=truststore.p12=ssl/truststore.p12 \
    -n $NAMESPACE --dry-run=client -o yaml | kubectl apply -f -

    The JVM reads the truststore at startup, so a running Kestra keeps the old file until its pods or containers restart.

  • When your internal root CA rotates. Import the new root under a new alias, and keep the old alias until no server presents a certificate signed by the old root.

Alternative: bake the CA into a custom image

If you build your own Kestra image, import the CA into the image’s cacerts at build time. The CA list then follows each base image you build from, and you don’t need JAVA_OPTS or a mounted file:

FROM registry.kestra.io/docker/kestra:latest
USER root
COPY internal-root-ca.pem /tmp/internal-root-ca.pem
RUN keytool -importcert -cacerts -noprompt \
-alias internal-root-ca \
-file /tmp/internal-root-ca.pem \
-storepass changeit \
&& rm /tmp/internal-root-ca.pem
USER kestra

Rebuild the image for every Kestra version you deploy.

Alternative: add the CA at container start (Docker and Docker Compose)

The Kestra image is based on Eclipse Temurin, which ships a /__cacert_entrypoint.sh script that adds CA certificates to the JVM truststore when the container starts. The truststore is then built from the cacerts of the image you run, so there’s nothing to rebuild when you upgrade, and you don’t set javax.net.ssl.trustStore yourself.

Mount the CA as a .crt file under /certificates, set USE_SYSTEM_CA_CERTS, and run the script before Kestra’s own entrypoint:

services:
kestra:
image: registry.kestra.io/docker/kestra:latest
entrypoint: ["/__cacert_entrypoint.sh", "docker-entrypoint.sh"]
volumes:
- ./ssl/internal-root-ca.pem:/certificates/internal-root-ca.crt:ro
# ...your existing volumes
environment:
USE_SYSTEM_CA_CERTS: "1"
# ...your existing environment variables
  • USE_SYSTEM_CA_CERTS alone has no effect: the Kestra image starts with docker-entrypoint.sh, so the script runs only when you set the entrypoint as shown.
  • The script reads only files ending in .crt from /certificates.
  • As the default kestra user, the script writes a copy of the truststore to /tmp and passes it to the JVM through JAVA_TOOL_OPTIONS, so only the JVM trusts your CA. When the container runs as root, the script also adds the CA to the operating system’s CA bundle, which commands run by the Process task runner use.
  • Don’t also set -Djavax.net.ssl.trustStore in JAVA_OPTS: it takes precedence over the truststore the script creates, and the JVM no longer trusts your CA.
  • The Helm chart replaces the container command, so the image entrypoint doesn’t run there. On Kubernetes, use the Secret-based setup above.
  • The script comes from the Eclipse Temurin base image, not from Kestra.

Was this page helpful?