colima: How to add trust unknown ssl authority or manually download and use iso

Is it possible to skip ssl check? We are using antivirus with MITM ssl certificate.

colima start --cpu 6 --memory 8 --disk 60 | more
INFO[0000] starting colima                              
INFO[0000] starting ...                                  context=vm
time="2022-01-18T13:17:29+01:00" level=info msg="Using the existing instance \"colima\""
time="2022-01-18T13:17:29+01:00" level=info msg="Attempting to download the image from \"https://github.com/abiosoft/alpine-lima/releases/download/colima-v0.3.2/alpine-lima-clm-3.14.3-x86_64.iso\"" digest="sha512:875482176ff2f43bf9472f84137d8b9a56d692ae19243436079c7f2f78cb6b13576601eef9102aaea796629215fc60308e69b590c81fe4139e9e84f1ec4a57f5"
time="2022-01-18T13:17:29+01:00" level=fatal msg="failed to download the image, attempted 2 candidates, errors=[unsupported arch: \"aarch64\" failed to download \"https://github.com/abiosoft/alpine-lima/releases/download/colima-v0.3.2/alpine-lima-clm-3.14.3-x86_64.iso\": Get \"https://objects.githubusercontent.com/github-production-release-asset-2e65be/422815134/912100a2-63cc-4bb2-ac99-e0940a5af5f5?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220118%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220118T121636Z&X-Amz-Expires=300&X-Amz-Signature=3d7b0a81026ed973ff0a64b8d9141f6104dcc775c35d2300dffc4c1283379e6d&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=422815134&response-content-disposition=attachment%3B%20filename%3Dalpine-lima-clm-3.14.3-x86_64.iso&response-content-type=application%2Foctet-stream\": x509: certificate signed by unknown authority]"
FATA[0000] error starting vm: error at 'starting': exit status 1 

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 53 (10 by maintainers)

Commits related to this issue

Most upvoted comments

This is what worked for me, mostly based on @momo182, to automatically pull the mitm certificate and trust it. The reason for doing it this way is:

  1. I’m not actually sure where the certificate resides on my operating system (might be just in the keychain?)
  2. If you run any kind of docker build commands that include package management, you need to re-run these commands inside the container itself too before using the package manager or wget, since container needs to trust these too.
  3. Supports multiple certificates in the chain (should only have to trust root, but idk).

Initially, docker pull hello-world fails with tls error error pulling image configuration: download failed after attempts=6: tls: failed to verify certificate: x509: certificate signed by unknown authority. You can plug in this one-liner to trust whatever certs https registry.hub.docker.com serves automatically:

colima ssh -- sudo sh -c 'cd /etc/ssl/certs && openssl s_client -showcerts -connect registry.hub.docker.com:443 < /dev/null | awk "/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/ {if (/-----BEGIN CERTIFICATE-----/) {if (out) close(out); out=\"certificate_mitm_\" ++n \".pem\"}; print > out}" && update-ca-certificates --fresh' && colima restart

Now, you can test and docker pull hello-world should succeed. You’ll have to stick something similar in your Dockerfile, here it is not as a one-liner for readability (and might be different depending on base image):

cd /etc/ssl/certs
openssl s_client -showcerts -connect registry.hub.docker.com:443 < /dev/null | awk '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/ {if (/-----BEGIN CERTIFICATE-----/) {if (out) close(out); out="certificate_mitm_" ++n ".pem"}; print > out}'
update-ca-certificates --fresh

Of course, the base Ubuntu and other images don’t always have the tools installed, but to install them using apt-get or dnf you’ll need to pull them from secure repos. You can probably inject certs or tools from the host or do it manually, but can just pull the tools usually ignoring insecure certificates.

RUN apt-get update && apt-get install -y -o Acquire::https::Verify-Peer=false openssl ca-certificates

here’s what i did to have it fixed:

colima ssh
sudo -s
cd /etc/ssl/certs
openssl s_client -showcerts -connect some.local.repo:8080 < /dev/null | awk '/-----BEGIN CERTIFICATE-----/ {p=1}; p; /-----END CERTIFICATE-----/ {p=0}' > ./some.local.repo.pem
update-ca-certificates --fresh
systemctl restart docker

Hello all, I am on macOS and created this script which resolved SSL issues for me. It exports the root certificates from the macOS Keychain, configures Colima to use these certificates, and restarts the Docker daemon. Sharing in case it proves helpful to someone else.


#!/bin/bash

# Create directories
mkdir -p ~/.ca-certificates
mkdir -p ~/.colima/default

# Export certificates from Keychain
security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain > ~/.ca-certificates/root_certs.pem
security find-certificate -a -p /Library/Keychains/System.keychain >> ~/.ca-certificates/root_certs.pem

# Create or update Colima configuration
cat << EOF > ~/.colima/default/colima.yaml
provision:
  - mode: system
    script: |
      CERTS="/Users/$(whoami)/.ca-certificates"
      cp \${CERTS}/* /usr/local/share/ca-certificates/
      update-ca-certificates
      systemctl daemon-reload
      systemctl restart docker
EOF

# Stop Colima if it's running
colima stop

# Start Colima with the new configuration
colima start

echo "Certificates exported and Colima configured and restarted"

For those on Mac, I figured out the process. You’ve to just manually update the default template file by running colima template and then edit the docker: {} to

docker:
  insecure-registries:
    - myregistry.com:5000
    - host.docker.internal:5000
    - etc....

– bump

How can I add my corp cert into the VM so that it can pull down images?

I had the same issue and was able to resolve it cleanly with a variation of the above for colima.

mkdir -p ~/.docker/certs.d
cp /PATH/TO/YOUR/CORP_OR_AV.cer ~/.docker/certs.d/CORP_OR_AV.crt
 # NOTE: If your CA was provided as a .cer file, be sure to rename it as .crt when copying it over.
colima stop
colima start

I would copy the certificate to /usr/local/share/ca-certificates and then run /usr/sbin/update-ca-certificates, followed by rc-service docker restart (based on my knowledge of the Alpine image; not sure if colima needs something in addition).

For MacOS, this did the trick for me: cp ca_keychain.pem $HOME/.docker/certs.d

I was unable to docker pull, but the following steps solved the problem. Maybe this will help.

The cause was VPN software, but the situation was the same as the Avast case described in this comment.

Fortunately, I was able to get the cert file and used it (hereafter referred to as xxx.crt).

# Assume the working directory is the directory where xxx.crt exists.

colima ssh

# Copy xxx.crt from the host.
sudo cp xxx.crt /usr/local/share/ca-certificates/

# Apply
sudo update-ca-certificates

# Check: should hit 2 lines
ls -la /etc/ssl/certs/ | grep xxx.crt

# docker restart or
exit

# colima restart
colima restart

# Make sure you can docker pull
docker pull hello-world

I think you are basically doing the same thing with your comment here.

on a similar issue, i had been encountering issues with my new proxy. To fix it, i did the following:

have colima running 
run in a terminal:
limactl shell colima
sudo vi /etc/ssl/certs/ca-certificates.crt
append the <proxy> pem certificate to the end of the file 	
save it 
exit shell
restart colima

I was unable to docker pull, but the following steps solved the problem. Maybe this will help.

The cause was VPN software, but the situation was the same as the Avast case described in this comment.

Fortunately, I was able to get the cert file and used it (hereafter referred to as xxx.crt).

# Assume the working directory is the directory where xxx.crt exists.

colima ssh

# Copy xxx.crt from the host.
sudo cp xxx.crt /usr/local/share/ca-certificates/

# Apply
sudo update-ca-certificates

# Check: should hit 2 lines
ls -la /etc/ssl/certs/ | grep xxx.crt

# docker restart or
exit

# colima restart
colima restart

# Make sure you can docker pull
docker pull hello-world

I think you are basically doing the same thing with your comment here.

This worked for me on MacOS Sequoia.

I found the Keychain Access app is still available at /Library/CoreServices/Applications so I opened it from there in Finder, exported my company’s internal root certificate to my home directory, then sudo copied it to /usr/local/share/ca-certificates/companyname.crt (file extension is apparently important, as update-ca-certificates will ignore files with .pem extension)

Then I ran sudo update-ca-certificates and restarted the VM as instructed, and now I can pull again. Thank you!

it doesn’t seem that colima is respecting host certs, such as /etc/docker/certs.d/*. Using Colima with a private registry gives me this

docker login <private_reg>
...
Error response from daemon: Get "<private_reg>": x509: certificate signed by unknown authority

This is with latest (as of today)

colima version
colima version HEAD-272db47
git commit: 272db4732b90390232ed9bdba955877f46a50552

runtime: docker
arch: x86_64
client: v20.10.12
server: v20.10.11

I had the same issue and was able to resolve it cleanly with a variation of the above for colima.

mkdir -p ~/.docker/certs.d
cp /PATH/TO/YOUR/CORP_OR_AV.cer ~/.docker/certs.d/CORP_OR_AV.crt
 # NOTE: If your CA was provided as a .cer file, be sure to rename it as .crt when copying it over.
colima stop
colima start

This worked for me instead of creating a dir named after the cert URI as stated in Docker docs.

The workarounds worked on 0.5.6, but don’t appear to work on 0.6.x.

Was not able to resolve this with any of the above workarounds

Hi, I went with the unsecure approach but maybe this pages help:

Self signed: https://docs.docker.com/registry/insecure/#use-self-signed-certificates

Unsecure: https://docs.docker.com/registry/insecure/#deploy-a-plain-http-registry

Every change using colima template requires a colima stop, colima start. You can check the status of the colima instance by executing limactl shell colima and then:

colima:/Users/user$ ls /etc/docker/certs.d/
colima:/Users/user$ cat /etc/docker/daemon.json
{
  "exec-opts": [
    "native.cgroupdriver=cgroupfs"
  ],
  "features": {
    "buildkit": true
  },
  "host-gateway-ip": "192.168.5.2",
  "insecure-registries": [
    "https://registry.xxx:443",
    "https://registry.xxx"
  ]
}

I am wondering however if I can use cli for configurations overrides, I noticed there is a --env option, but not documented or no examples found

At the moment, it can only be configured via the config file.