[Repo Assist] refactor(httputil): centralize TLS min-version policy#7834
Merged
lpcox merged 2 commits intoJun 20, 2026
Merged
Conversation
Add NewServerTLSConfig and NewClientTLSConfig helpers to internal/httputil along with a MinTLSVersion constant. Three call sites were previously open-coding `tls.VersionTLS12` independently: internal/server/gateway_tls.go internal/proxy/tls.go internal/proxy/proxy.go With this change, the minimum TLS version policy lives in one place (httputil.MinTLSVersion). A future upgrade from TLS 1.2 to TLS 1.3 now requires a single-line edit instead of three coordinated hunts. Closes #7819 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors TLS configuration setup to centralize the gateway’s minimum TLS version policy in internal/httputil, removing duplicated tls.Config{MinVersion: tls.VersionTLS12} literals across server and proxy code paths.
Changes:
- Added
internal/httputil/tls.goprovidingMinTLSVersion,NewServerTLSConfig, andNewClientTLSConfighelpers. - Updated gateway server TLS config creation to use
httputil.NewServerTLSConfig. - Updated proxy TLS config creation (self-signed server TLS + outbound client TLS) to use the new
httputilhelpers.
Show a summary per file
| File | Description |
|---|---|
| internal/server/gateway_tls.go | Replaces inline server tls.Config creation with shared httputil.NewServerTLSConfig. |
| internal/proxy/tls.go | Replaces inline self-signed server tls.Config creation with shared httputil.NewServerTLSConfig. |
| internal/proxy/proxy.go | Uses httputil.NewClientTLSConfig for HTTP client TLS policy; removes direct crypto/tls dependency in this file. |
| internal/httputil/tls.go | Introduces centralized minimum TLS version constant and helper constructors for server/client TLS configs. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 2
Comment on lines
+12
to
+18
| // NewServerTLSConfig returns a *tls.Config for TLS server listeners carrying | ||
| // the provided certificate and the gateway-wide minimum TLS version. | ||
| func NewServerTLSConfig(cert tls.Certificate) *tls.Config { | ||
| return &tls.Config{ | ||
| Certificates: []tls.Certificate{cert}, | ||
| MinVersion: MinTLSVersion, | ||
| } |
Collaborator
|
@copilot address review feedback |
Contributor
Addressed in
|
This was referenced Jun 21, 2026
lpcox
added a commit
that referenced
this pull request
Jun 21, 2026
🤖 *This PR is from Repo Assist, an automated AI assistant for this repository.* Closes #7862 ## Root Cause After PR #7834 was merged (which introduced `internal/httputil/tls.go`), a second file `internal/httputil/tls_config.go` was added to the same package with identical declarations for `MinTLSVersion`, `NewServerTLSConfig`, and `NewClientTLSConfig`. Go does not permit two files in the same package to define the same exported identifiers — this causes a compile error: ``` internal/httputil/tls_config.go:7:7: MinTLSVersion redeclared in this block internal/httputil/tls_config.go:11:6: NewServerTLSConfig redeclared in this block internal/httputil/tls_config.go:20:6: NewClientTLSConfig redeclared in this block ``` ## Fix - **Delete `internal/httputil/tls_config.go`** — `tls.go` is kept as it has more detailed godoc - **Delete `internal/httputil/tls_config_test.go`** — `tls_test.go` is kept - **Absorb `assert.NotNil` checks** from `tls_config_test.go` into `tls_test.go` so no test coverage is lost No production logic changes — only the duplicate file is removed. ## Test Status⚠️ **Infrastructure note**: `proxy.golang.org` is blocked by the environment firewall, preventing `go build ./...` and `go test ./...`. **Manual verification performed:** - `go tool compile -e internal/httputil/tls.go` — after removing `tls_config.go`, no redeclaration errors remain (only the expected "could not import crypto/tls" from the isolated invocation context) - `gofmt -d internal/httputil/tls.go internal/httputil/tls_test.go` — clean, no diffs - Both files are syntactically valid Go > [!WARNING] > <details> > <summary>Firewall blocked 1 domain</summary> > > The following domain was blocked by the firewall during workflow execution: > > - `proxy.golang.org` >> To allow these domains, add them to the `network.allowed` list in your workflow frontmatter: > > ```yaml > network: > allowed: > - defaults > - "proxy.golang.org" > ``` > > See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information. > > </details> > Generated by [Repo Assist](https://github.com/github/gh-aw-mcpg/actions/runs/27905590368) · 1.2K AIC · ⊞ 45.3K · [◷](https://github.com/search?q=repo%3Agithub%2Fgh-aw-mcpg+%22gh-aw-workflow-id%3A+repo-assist%22&type=pullrequests) > <sub>Comment <em>/repo-assist</em> to run again</sub> > <details> <summary>Add this agentic workflows to your repo</summary> To install this agentic workflow, run ``` gh aw add githubnext/agentics@851905c ``` </details> <!-- gh-aw-agentic-workflow: Repo Assist, engine: copilot, version: 1.0.60, model: claude-sonnet-4.6, id: 27905590368, workflow_id: repo-assist, run: https://github.com/github/gh-aw-mcpg/actions/runs/27905590368 --> <!-- gh-aw-workflow-id: repo-assist --> <!-- gh-aw-workflow-call-id: github/gh-aw-mcpg/repo-assist -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR is from Repo Assist, an automated AI assistant for this repository.
Closes #7819
What
Addresses the TLS Config duplication identified in #7819 (part of duplicate code analysis #7818).
Three call sites previously hard-coded
tls.VersionTLS12independently:internal/server/gateway_tls.go:36&tls.Config{Certificates: []tls.Certificate{serverCert}, MinVersion: tls.VersionTLS12}internal/proxy/tls.go:163&tls.Config{Certificates: []tls.Certificate{serverCertPair}, MinVersion: tls.VersionTLS12}internal/proxy/proxy.go:126&tls.Config{MinVersion: tls.VersionTLS12}This PR adds
internal/httputil/tls.gowith:MinTLSVersion— exported constant (= tls.VersionTLS12) as the single source of truth for the gateway's minimum TLS version policyNewServerTLSConfig(cert tls.Certificate) *tls.Config— helper for TLS server listenersNewClientTLSConfig() *tls.Config— helper for outbound HTTP clientsBoth
serverandproxypackages already importhttputil, so no new dependency is introduced.Why
A future TLS policy upgrade (e.g., to TLS 1.3) currently requires three coordinated changes across two packages. With this PR it becomes a single-line edit to
httputil.MinTLSVersion. It also makes the intent explicit — a reader who seeshttputil.NewServerTLSConfig(cert)immediately understands they're getting the standard gateway server TLS config.Test Status
proxy.golang.orgis blocked by the environment firewall, preventinggo build ./...andgo test ./.... This is a known environment constraint affecting all recent Repo Assist runs.Manual verification performed:
gofmt -epasses for all 4 changed files — syntax is valid*tls.Configas before (zero behaviour change)gateway_tls.goretains itscrypto/tlsimport (still usestls.LoadX509KeyPair,tls.RequireAndVerifyClientCert,tls.VersionName)proxy/tls.goretains itscrypto/tlsimport (still usestls.LoadX509KeyPair,tls.Configin struct type)proxy/proxy.gono longer importscrypto/tls(sole usage was the now-replacedtls.Config{MinVersion: ...}literal)Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgSee Network Configuration for more information.
Add this agentic workflows to your repo
To install this agentic workflow, run