Go programs only check the host name against a certificate's subjectAltName. If it has just a Common Name, crane, regctl, oras, cosign, Podman and containerd reject it – while curl falls back to the CN via OpenSSL and is happy.
Symptom
curl -sS "https://$T/v2/"; echo " curl: $?"
crane copy "$REG/notes/notes-api:0.1.0" "$T/notes/notes-api:0.1.0" 2>&1 | tail -1
registry.ct.lab:5001
{} curl: 0
Error: Get "https://registry.ct.lab:5001/v2/": tls: failed to verify certificate: x509:
certificate relies on legacy Common Name field, use SANs instead
“curl works, so it must be crane.” The test registry has a certificate from the lab's own CA.
Diagnosis
Put the test registry's certificate next to the working one.
openssl s_client -connect "$T" -servername "$REG_HOST" </dev/null 2>/dev/null \
| openssl x509 -noout -subject -issuer -ext subjectAltName
openssl x509 -in "$LAB/registry/certs/registry.crt" -noout -ext subjectAltName
subject=CN=registry.ct.lab
issuer=CN=ct-lab CA (ubuntu)
No extensions in certificate
X509v3 Subject Alternative Name:
DNS:registry.ct.lab
Causes
CN onlyNo subjectAltName in the certificate
CA and CN are right, but the subjectAltName extension is missing. Since Go 1.15, Go ignores the CN for name checks.
curlcurl is the wrong witness
curl (OpenSSL) falls back to the CN without a SAN. That curl works proves nothing for Go-based tools.
Fix
openssl x509 -req -in certs/test.csr -CA "$ca/ca.crt" -CAkey "$ca/ca.key" \
-CAcreateserial -days 30 -extfile "$ca/ext.cnf" -out certs/test.crt
openssl x509 -in certs/test.crt -noout -ext subjectAltName
podman restart r15-registry >/dev/null && sleep 2
X509v3 Subject Alternative Name:
DNS:registry.ct.lab
Don't: Carry on with --insecure or an exception in registries.conf – then nobody checks which registry you are talking to.
Container tools hands-on, Day 16: repair ten broken container setups with Podman, Quadlet, crane, skopeo and cosign.
Go to day 16 →
FAQ
Which tools are affected?
All written in Go – crane, regctl, oras, cosign, Podman, containerd, but also kubectl and Helm.
Do I need a new key?
No. The CSR and the key stay; only the signature with the SAN extension is new.