Skip to content

Introducing configurable setting for min tls version#199

Open
pebanb wants to merge 2 commits intobasecamp:mainfrom
pebanb:feature/tls1_3_per_config
Open

Introducing configurable setting for min tls version#199
pebanb wants to merge 2 commits intobasecamp:mainfrom
pebanb:feature/tls1_3_per_config

Conversation

@pebanb
Copy link
Copy Markdown

@pebanb pebanb commented Mar 19, 2026

Introducing TLS 1.3 as a config flag for more secure server.
An improvement vs #190
Adding also test coverage for the new feature.

Copilot AI review requested due to automatic review settings March 19, 2026 13:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an (intended) configuration option to require TLS 1.3 as the minimum TLS version for the HTTPS server, while preserving existing TLS/ALPN configuration.

Changes:

  • Add OnlyTLS1_3 to internal/server.Config to control whether HTTPS enforces MinVersion = tls.VersionTLS13.
  • Refactor HTTPS server initialization to reuse a tls.Config instance and conditionally set MinVersion.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
internal/server/server.go Creates a reusable TLS config for the HTTPS server and conditionally enforces TLS 1.3 minimum.
internal/server/config.go Adds a new config field meant to control the TLS 1.3 minimum-version behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pebanb pebanb force-pushed the feature/tls1_3_per_config branch from 898c406 to 627aded Compare March 20, 2026 12:05
@pebanb pebanb force-pushed the feature/tls1_3_per_config branch from 627aded to 6d6be08 Compare March 20, 2026 12:15
@AnyCPU
Copy link
Copy Markdown
Contributor

AnyCPU commented Mar 20, 2026

@pebanb my mr just makes implicit explicit, no change in behavior, the same was done for http3.

in your case I would add a --min-tls option that defaults to 1.2 to preserve standard existing behavior.

@pebanb
Copy link
Copy Markdown
Author

pebanb commented Mar 20, 2026

@pebanb my mr just makes implicit explicit, no change in behavior, the same was done for http3.

in your case I would add a --min-tls option that defaults to 1.2 to preserve standard existing behavior.

hi @AnyCPU the standard existing behavior is kept, it's just possible to force tls 1.3 by a configuration if required for some application, which require to enforce only new ciphers.

@AnyCPU
Copy link
Copy Markdown
Contributor

AnyCPU commented Mar 20, 2026

@pebanb I know I saw the source code, in more generic case --min-tls and default "1.2" it is possible to resolve both mrs:

  • more explicit value in specific source code (kamal-proxy) than implicit underground of Go;
  • and in uniform way you are able to force "1.3" version when needed;
  • as a bonus it will be extremely easy to add upcoming "1.4" when needed.

from dev/ux it is easier to remember a --min-tls name than a --min-tls13 bool flag.

Copilot AI review requested due to automatic review settings March 26, 2026 12:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a configurable minimum TLS version for the HTTPS (h1/h2) server, wiring it through CLI/env config and extending tests to cover the new option.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Changes:

  • Introduce Config.MinTLS and a --min-tls / MIN_TLS configuration path.
  • Apply the configured TLS minimum version to the HTTPS server’s tls.Config.
  • Extend HTTPS deployment tests with new subtests for various minimum TLS values.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/server/testing.go Extends the test server helper to pass through MinTLS config.
internal/server/server_test.go Adds subtests intended to validate different configured minimum TLS versions.
internal/server/server.go Builds an HTTPS tls.Config with MinVersion based on config (and errors on invalid values).
internal/server/config.go Adds MinTLS to server configuration struct.
internal/cmd/util.go Adds getEnvString helper for string-valued env configuration.
internal/cmd/run.go Adds --min-tls flag (and MIN_TLS env support) to populate Config.MinTLS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +80 to +84
require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
assert.Equal(t, "HTTP/1.1", resp.Proto)
assert.GreaterOrEqual(t, resp.TLS.Version, uint16(tls.VersionTLS10))
})
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The new min-TLS subtests don't actually verify that the server enforces the configured minimum: asserting resp.TLS.Version >= TLS1.0/1.1/1.2 will pass even if the server ignores MinTLS (because the negotiated version is commonly higher anyway). Consider asserting the server's configured MinVersion directly (tests are in the same package, so you can read server.httpsServer.TLSConfig.MinVersion), and/or add a negative handshake test by forcing the client MaxVersion below the configured minimum and asserting the request fails.

Copilot uses AI. Check for mistakes.
case "tls1_3":
tlsConfig.MinVersion = tls.VersionTLS13
case "":
// No minimum TLS version set
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

When MinTLS is empty, the HTTPS server TLS config leaves MinVersion unset. That means the effective minimum is Go's runtime default, which can be changed by environment/runtime settings and may not meet the PR's stated goal of hardening the server. If the intent is to be secure by default, consider setting an explicit default minimum (e.g., TLS 1.2) when MinTLS is not provided, and reserve an explicit opt-out value if you need to preserve legacy behavior.

Suggested change
// No minimum TLS version set
// Default to a secure minimum TLS version when not explicitly configured.
tlsConfig.MinVersion = tls.VersionTLS12

Copilot uses AI. Check for mistakes.
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.

default and empty case should use tls 1.2 because Go does it implicitly at the moment.

Comment on lines +168 to +170
default:
return fmt.Errorf("unsupported minimum TLS version: %q (use tls1_0, tls1_1, tls1_2, or tls1_3)", s.config.MinTLS)
}
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The new error branch for unsupported MinTLS values is user-facing behavior but isn't covered by tests. Adding a small test that sets Config.MinTLS to an invalid value and asserts Server.Start() fails with this error would help prevent regressions (especially since the flag/env input is free-form).

Copilot uses AI. Check for mistakes.
@pebanb pebanb changed the title Introducing configurable setting for tls 1.3. as min version Introducing configurable setting for min tls version Mar 26, 2026
@pebanb
Copy link
Copy Markdown
Author

pebanb commented Mar 26, 2026

@pebanb I know I saw the source code, in more generic case --min-tls and default "1.2" it is possible to resolve both mrs:

  • more explicit value in specific source code (kamal-proxy) than implicit underground of Go;
  • and in uniform way you are able to force "1.3" version when needed;
  • as a bonus it will be extremely easy to add upcoming "1.4" when needed.

from dev/ux it is easier to remember a --min-tls name than a --min-tls13 bool flag.

hi, introduced configurable min tls version, now you can set each version you need :)

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.

4 participants