Skip to content

Go: Pass proxy certificate to git via GIT_SSL_CAINFO - #22897

Merged
jketema merged 2 commits into
mainfrom
go/proxy-git-cainfo-env-pr2
Oct 26, 2026
Merged

jketema merged 2 commits into
mainfrom
go/proxy-git-cainfo-env-pr2

Conversation

@jketema

@jketema jketema commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Pass the registry proxy CA certificate to Git subprocesses via GIT_SSL_CAINFO in the Go command environment.
  • Add a unit test for the certificate environment variables and a Go library change note.

Validation

  • go test ./registries

The extractor ran `git config --global http.sslCAInfo <temp cert>` when
private `git_source` registries were configured. That permanently modified
the user's global git configuration, and on non-ephemeral (e.g. self-hosted)
runners it kept pointing at a temporary certificate file after the job
finished, breaking later git HTTPS operations.

Instead, set `GIT_SSL_CAINFO` alongside `SSL_CERT_FILE` in the environment
that `ApplyProxyEnvVars` applies to `go` commands. This is picked up by the
`git` processes `go` spawns, and is scoped to those subprocesses.

Co-authored-by: Copilot <[email protected]>
@jketema
jketema requested review from a team as code owners October 26, 2026 13:09
Copilot AI max review requested due to automatic review settings October 26, 2026 13:09
Document the proxy certificate behavior without referring to the previous global Git configuration, and add a change note.

Co-authored-by: Copilot <[email protected]>
@jketema
jketema force-pushed the go/proxy-git-cainfo-env-pr2 branch from ab0398d to 18094d8 Compare October 26, 2026 13:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The broader Git certificate-trust scope needs human validation, and dependency-loading paths still omit the proxy CA environment.

1 open issue
What changed in this PR

This PR moves the Go extractor’s registry-proxy certificate configuration from global Git settings to subprocess environment variables, avoiding persistent changes to the user’s Git configuration.

Changes:

  • Pass the proxy CA through GIT_SSL_CAINFO alongside SSL_CERT_FILE.
  • Add a unit test checking both certificate environment variables.
  • Add a Go library change note.
File Description
go/​ql/​lib/​change-notes/​2026-10-26-registry-proxy-certificate.md Documents proxy certificate handling.
go/​extractor/​registries/​registryproxy.go Replaces global Git configuration with an environment variable.
go/​extractor/​registries/​registryproxy_test.go Checks that both certificate variables reference the temporary file.

Review effort: Max

result = append(
result,
fmt.Sprintf("SSL_CERT_FILE=%s", proxy_cert_file),
fmt.Sprintf("GIT_SSL_CAINFO=%s", proxy_cert_file),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was already the case for SSL_CERT_FILE. So this seems out-of-scope of this PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ListWithEnv replaces the environment configured by GoCommand (go/extractor/toolchain/toolchain.go:226–227), and packages.Load receives no proxy environment (go/extractor/extractor.go:176–185).

These are existing (potential) issues unrelated to the change in this PR.

Removing the global http.sslCAInfo setting therefore leaves Git fetches from these paths without the proxy CA, so uncached private modules can fail certificate verification. Preserve the configured environment in ListWithEnv, pass it through packages.Config.Env, and add regression coverage for both paths.

This is logically disconnected from the previous part. If we don't configure the proxy for the above commands, then the certificate is also not needed. We either need everything at once or nothing.

I don't think we should address that some commands don't get the proxy environment in this PR. We haven't received any indications that this is a problem right now.


The behavioural change here is that we now always set GIT_SSL_CAINFO if the proxy is running, even if there are no git_source registries configured. Previously, we'd only run git config if there was at least one git_source.

This change makes sense though, because we previously also set the HTTP(S)_PROXY environment variables regardless of whether there was a git_source or not. The new behaviour for GIT_SSL_CAINFO makes sense with respect to that.

@mbg mbg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here look good to me. I don't think Copilot's comment is about the change in this PR. While there is a slight behavioural change in when we set GIT_SSL_CAINFO compared to when we called git config before, that makes sense to me since we also always set the proxy vars as long as the proxy is running.

result = append(
result,
fmt.Sprintf("SSL_CERT_FILE=%s", proxy_cert_file),
fmt.Sprintf("GIT_SSL_CAINFO=%s", proxy_cert_file),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ListWithEnv replaces the environment configured by GoCommand (go/extractor/toolchain/toolchain.go:226–227), and packages.Load receives no proxy environment (go/extractor/extractor.go:176–185).

These are existing (potential) issues unrelated to the change in this PR.

Removing the global http.sslCAInfo setting therefore leaves Git fetches from these paths without the proxy CA, so uncached private modules can fail certificate verification. Preserve the configured environment in ListWithEnv, pass it through packages.Config.Env, and add regression coverage for both paths.

This is logically disconnected from the previous part. If we don't configure the proxy for the above commands, then the certificate is also not needed. We either need everything at once or nothing.

I don't think we should address that some commands don't get the proxy environment in this PR. We haven't received any indications that this is a problem right now.


The behavioural change here is that we now always set GIT_SSL_CAINFO if the proxy is running, even if there are no git_source registries configured. Previously, we'd only run git config if there was at least one git_source.

This change makes sense though, because we previously also set the HTTP(S)_PROXY environment variables regardless of whether there was a git_source or not. The new behaviour for GIT_SSL_CAINFO makes sense with respect to that.

@jketema
jketema merged commit ac59cbf into main Oct 26, 2026
18 checks passed
@jketema
jketema deleted the go/proxy-git-cainfo-env-pr2 branch October 26, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants