Custom CA certificate trust on GitHub-hosted runners for internal artifact registries
0 reputation · 08 Sept 2020, 11:22 UTC
0 reputation · 08 Sept 2020, 11:22 UTC
Configure a GitHub Actions workflow running on GitHub-hosted runners to connect to an internal HTTPS artifact registry whose certificate is issued by a private CA.
GitHub-hosted runners do not expose a supported way to modify the system certificate trust store or inject a custom CA at job start. DNS resolution uses GitHub's internal resolvers and cannot reach private domain names without private networking, which has plan and region limitations. Trust behavior also varies across git, npm, pip, and Docker, so configuring one tool does not necessarily trust the CA for others.
It is unclear whether a runner-level or job-level configuration exists that makes a private CA trusted across all workflow tools without switching to self-hosted runners.
37275 reputation · 08 Sept 2020, 13:03 UTC
GIT_SSL_CAINFO or http.sslCAInfo; Node and npm use NODE_EXTRA_CA_CERTS; Python and pip use REQUESTS_CA_BUNDLE or PIP_CERT; Docker on hosted runners uses the daemon trust store, which you cannot modify without privileged access. Setting one variable does not cover the other tools. DNS for private hostnames remains blocked on standard hosted runners because they use public resolvers; private names do not resolve unless you use GitHub Enterprise Cloud private networking.| Confirmed | Likely or inferred |
|---|---|
| No GitHub Actions feature injects a CA into the hosted runner system store. | Future runner images will not add this without a documented feature release. |
| Tool-specific env vars are the documented way to extend trust per process. | Some older pip or Docker client versions may ignore the standard vars and require config-file edits. |
| Standard hosted runners cannot resolve private DNS zones. | Private networking is the only GitHub-supported path to private DNS on hosted runners. |
| Private networking does not install CAs into the OS store. | It also does not propagate a CA to the Docker daemon on the runner. |
Store the CA certificate PEM public cert only as a repository or organization secret named INTERNAL_CA_PEM. In each job that talks to the internal registry:
jobs:
build:
runs-on: ubuntu-latest
env:
GIT_SSL_CAINFO: /tmp/internal-ca.pem
NODE_EXTRA_CA_CERTS: /tmp/internal-ca.pem
REQUESTS_CA_BUNDLE: /tmp/internal-ca.pem
PIP_CERT: /tmp/internal-ca.pem
steps:
- name: Write CA to temp file
run: printf '%s\n' "${{ secrets.INTERNAL_CA_PEM }}" > /tmp/internal-ca.pem
- name: Verify git trust
run: git ls-remote https://internal-registry.example.com/repo.git
- name: Verify npm trust
run: npm config set registry https://internal-registry.example.com/npm/; npm ping
- name: Verify pip trust
run: pip index versions --index-url https://internal-registry.example.com/pypi/simple/ some-package
The Docker daemon on GitHub-hosted Linux runners uses the system trust store. You cannot add a CA to it without privileged operations that are not permitted on hosted runners.
/etc/docker/certs.d or the daemon trust store.Does your internal registry present a certificate from a public CA or strictly from a private CA? If it is a public CA, you likely need zero trust configuration; you only need private networking or a VPN for DNS reachability. This answer determines whether you configure per-tool trust at all.
curl -vI https://internal-registry.example.com before writing the CA file. Failure to resolve indicates a DNS or private-networking gap. TLS handshake failure indicates a trust gap.curl --cacert /tmp/internal-ca.pem -vI https://internal-registry.example.com after writing the CA file to confirm the certificate works.openssl s_client -connect internal-registry.example.com:443 -showcerts to inspect the chain the registry presents.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.