Docker Community Forums

Share and learn in the Docker community.

Validate Swarm Node Certificates

As a developer, i like to use Jenkins Automation server to trigger certain tasks. Some of these tasks should run on an external docker server. Fortunately, a plugin is available to do this. However it becomes difficult when trying to secure the connection between Jenkins and the remote Docker Instance. This is due to the way how e.g Swarm creates certificates for its’ nodes. Take the following example:

sudo docker swarm init
sudo docker swarm ca --rotate --ca-cert /home/myuser/ca.pem --ca-key /home/myuser/ca-key-decrypted.pem

This initializes the current node as a swarm manager and automatically creates certificates for each node, signed by the CA we defined. So far so good. Lets take a look at the certificate created for the node:

sudo openssl x509 -in /var/lib/docker/swarm/certificates/swarm-node.crt | openssl x509 -noout -text

The result looks like this:

    Version: 3 (0x2)
    Serial Number:
Signature Algorithm: sha512WithRSAEncryption
    Issuer: C=AB, ST=CD, O=EFGH,
        Not Before: Apr 23 09:14:00 2021 GMT
        Not After : Jul 22 10:14:00 2021 GMT
    Subject: O=bfhuczywedsxgk7qqlbewime9, OU=swarm-manager, CN=0il4objx3hnpuukfpmgnu1zqf
    Subject Public Key Info:
        Public Key Algorithm: id-ecPublicKey
            Public-Key: (256 bit)
            ASN1 OID: prime256v1
            NIST CURVE: P-256
    X509v3 extensions:
        X509v3 Key Usage: critical
            Digital Signature, Key Encipherment
        X509v3 Extended Key Usage:
            TLS Web Server Authentication, TLS Web Client Authentication
        X509v3 Basic Constraints: critical
        X509v3 Subject Key Identifier:
        X509v3 Authority Key Identifier:

        X509v3 Subject Alternative Name:
            DNS:swarm-manager, DNS:0il4objx3hnpuukfpmgnu1zqf, DNS:swarm-ca
Signature Algorithm: sha512WithRSAEncryption

When trying to connect to the socket where the dockerd of the swarm-node is listening on via TLS (tcp://, the certificate cannot be verified, as the SANs “swarm-manager”, “0il4objx3hnpuukfpmgnu1zqf”, “swarm-ca” dont match the hostname “”.

This leads to e.g. Jenkins not being able to connect to a remote docker instance, as the certificate will never contain the hostname “”. The certificate also does not contain an IP SAN to allow to connect securely.

Please let me know, how to handle this issue? It must be possible to connect to the API remotely without sacrificing security!

1 Like