question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

self signed certificates not working - "x509: certificate signed by unknown authority" error with private Docker repository

See original GitHub issue

Behaviour

Steps to reproduce this issue

  1. Create private Docker Registry with self signed certificates

  2. Create Github runner with ca-certificate mounted into /etc/docker/certs.d/docker-registry.actions-runner-system.svc\:5000/ca.crt, so that Docker can pull and push from a private registry with those certs

  3. Configure Github workflow yaml to use this certificate

      - name: Setup docker context for buildx
        id: buildx-context
        run: docker context create builders || docker context use builders
      - name: Copy ca cert
        run: |
          sudo cp /etc/docker/certs.d/docker-registry.actions-runner-system.svc\:5000/ca.crt /etc/ssl/certs/ca-certificates.crt
      - name: Create BuildKit Configuration
        run: |
          cat <<EOF > buildkitd.toml   
          [registry."docker-registry.actions-runner-system.svc:5000"]
            http = false
            insecure = false
            ca=["/etc/ssl/certs/ca-certificates.crt"]
          EOF
      - name: Setup Docker Buildx
        id: setup_docker_buildx
        uses: docker/setup-buildx-action@v1
        with:
          endpoint: builders
          buildkitd-flags: --debug
          config: buildkitd.toml
      - name: Build and push (broker)
        id: docker_build_broker
        uses: docker/build-push-action@v2
        with:
          file: Dockerfile
          push: false #deactivated for testing
          tags: someOtherRegistry/app:test
          cache-from: type=registry,ref=docker-registry.actions-runner-system.svc:5000/app:buildcache
          cache-to: type=registry,ref=docker-registry.actions-runner-system.svc:5000/app:buildcache,mode=max

Expected behaviour

My expectation is that “setup-buildx-action” should take the ca-certs from the Runner and use them in the moby/buildkit:buildx-stable-1 Docker container, where the build-push-action is executed. This is based on https://github.com/docker/buildx/pull/787#discussion_r734168450 - If I understood it correctly.

Actual behaviour

x509: certificate signed by unknown authority

image

Are my expectations are wrong or did I use some wrong configuration?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
aleksascommented, Dec 29, 2021

I don’t use github workflow or k8s so notation was not very clear. But yes I’ve managed to push the multi-arch image to secure repo. Created a buildkitd.toml

[registry."IP_ADDRESS:5000"]
http = false
insecure = false
ca=["/etc/ssl/certs/ca-certificates.crt"]

file and passed it while creating new buildx builder

docker buildx create --use --config buildkit.toml

Replace ca=["/etc/ssl/certs/ca-certificates.crt"] with ca=["/etc/pki/ca-trust/source/anchors/ca.crt"] for centos.

Was still getting x509: certificate signed by unknown authority on other machines trying to pull push image directly (without buildx) to the registry, but that was due to certificate not being recognized event after commands below. Had to restart the machines for certificate to be recognized. Maybe logging in/out would be enough…

Ubuntu:

sudo cp domain.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
sudo systemctl restart docker

Centos:

sudo cp domain.crt /etc/pki/ca-trust/source/anchors
sudo update-ca-trust extract
sudo systemctl restart docker
2reactions
crazy-maxcommented, Nov 9, 2021

@erichorwath This has been fixed with https://github.com/docker/buildx/pull/787 and available since 0.7.0-rc1:

      - name: Setup Docker Buildx
        id: setup_docker_buildx
        uses: docker/setup-buildx-action@v1
        with:
          version: v0.7.0-rc1
          endpoint: builders
          buildkitd-flags: --debug
          config: buildkitd.toml

Let us know if it works. I will also open a PR to update our doc here when 0.7.0 is GA.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Logging into your docker registry fails with x509 certificate - IBM
Logging into your docker registry fails with x509 certificate signed by unknown authority error. Problem. You cannot log in to your docker registry....
Read more >
Docker Private Registry: x509: certificate signed by unknown ...
I am attempting to setup a private docker registry, secured by a reverse nginx proxy that validates users by client certificates. The error...
Read more >
How to fix Docker error certificate signed by unknown authority ...
1: Create a file /etc/docker/daemon.json and add insecure-registries · 2: Restart the docker daemon by executing the command · 3: Create a directory...
Read more >
ERROR: x509: certificate signed by unknown authority error is ...
In this article, we will look at solving the problem with a self-signed certificate when trying to push an image to our own...
Read more >
"docker pull" certificate signed by unknown authority
You may need to restart the docker service to get it to detect the change in OS certificates. Docker does have an additional...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found