Skip to content

Support for intermediate certificates #683

Closed

Description

@rxbynerd

TLS certificates from Gandi need two intermediate certificates for them to actually work, without them, you get an error like this:

v2 ping attempt failed with error: Get https://deployment.rubynerd.net/v2/: x509: certificate signed by unknown authority

from the result of docker login https://deployment.rubynerd.net.

I don't have any experience with TLS in Go, but from my reading last night, it seems that I need to include the intermediate certificates Gandi have supplied me in this array.

I don't imagine I'm the first person to see this, nor will I be the last. The deployment guide states You can buy a certificate for as cheap as 10$ a year. These cheap 10$ certificates almost always depend on some sort of intermediate certificate, so end users following this "highly recommended" solution will find themselves trapped with a 10$ certificate they cannot use.

I consider this a necessary feature to deploy Docker Distribution, and I would like to discuss how this feature should be implemented. If nobody else feels up to the task, I am more than happy to roll up my sleeves and do it myself. However, this is my first time dealing with Go and this codebase, so I want to make sure I'm doing it the right way first.

In terms of proposed solutions, we could take inspiration from nginx, which allows you to concatenate your certificate with its intermediates into one file, which nginx then loads into the SSL context for you. Alternatively, we can specify a path of certificates to load, similarly to how a $PATH variable works in a shell.

I'm eager to hear your thoughts on how this can be resolved - I would like to get this docker registry off the ground as soon as possible as it's blocking other projects!

Activity

  1. taxilian commented on Jul 9, 2015

    @taxilian

    Here is how I started my registry instance:

    docker run -d -p 5000:5000 \
           -v /data/ssd/config/certs:/certs \
           -v /data/gradecam/registry:/var/lib/registry \
       -e REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/var/lib/registry \
       -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/combined.crt \
       -e REGISTRY_HTTP_TLS_KEY=/certs/STAR_zzt_net.key \
       --restart=always --name=registry registry:2
    

    Previous to this I did:

    cat  STAR_zzt.net.crt cacertfiles.cabundle > combined.crt
    
  2. stevvooe commented on Jul 9, 2015

    @stevvooe
    Collaborator

    Here was the first attempt, I believe: #453.

    I think we can close this when we have documentation showing how to join intermediate certificates for server cert.

  3. stevvooe commented on Jul 9, 2015

    @stevvooe
    Collaborator

    @taxilian Do you have the command to combine the certs appropriately?

  4. taxilian commented on Jul 9, 2015

    @taxilian

    Just updated my comment to have that

  5. taxilian commented on Jul 9, 2015

    @taxilian

    The basic syntax for the .crt file should be something like:

    ----BEGIN CERTIFICATE-----
    (your certificate here)
    -----END CERTIFICATE-----
    ----BEGIN CERTIFICATE-----
    (Chain cert 1 here)
    -----END CERTIFICATE-----
    ----BEGIN CERTIFICATE-----
    (Chain cert 2 here)
    -----END CERTIFICATE-----
    ----BEGIN CERTIFICATE-----
    (Chain cert 3 here)
    -----END CERTIFICATE-----
    

    Incidentally this is very similar to how nginx expects certificates come

  6. rxbynerd commented on Jul 9, 2015

    @rxbynerd
    ContributorAuthor

    Yup, turns out this feature all works as expected with nginx, I must have fudged up a cat command when I was first trying to get this deployed!

    To confirm, concatenating the certificates together with a command like cat server.crt GandiStandardSSLCA2.pem > server.with-intermediate.crt creates a certificate bundle which can be handled by Go's TLS LoadX509KeyPair, which distribution uses to load certificate files.

    I'll make a PR for some improved documentation about intermediate certs. Thanks @taxilian!

  7. stevvooe commented on Jul 9, 2015

    @stevvooe
    Collaborator

    @rxbynerd Re-opening until we merge #686.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions