feat(tpagectl): add TLS verification controls #597
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd!597
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/cli-tls-controls"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implements Phase 6 TLS verification controls (roadmap #261).
--insecure(#258) — new root flag (andinsecure/TPAGECTL_INSECUREconfig) that skips TLS certificate verification. Prints a warning to stderr:warning: TLS certificate verification disabled (--insecure).--ca-cert(#259) — new root flag (andca_cert/TPAGECTL_CA_CERTconfig) accepting a path to a PEM CA bundle. The bundle is appended to the system pool viax509.SystemCertPool(); a file with no certificates, or an unreadable file, errors before any request is made.Why
Roadmap task #261, the last item in Phase 6.
Testing
NewTLSConfignone/insecure/valid-CA (self-signed PEM)/no-certs/missing-file;WithTLSConfigwires the transport; defaultNewkeeps the nil transport (system pool)httptest.NewTLSServer:--insecureconnects and warns;--ca-cert <server cert>verifies without disabling verification; plainstatusfails on an untrusted cert (proves the system-pool default)--ca-certerrors earlygo test -race ./...passes (25 packages)golangci-lint runcleanBreaking Changes
None.
Notes
New
client.NewTLSConfig(insecure, caCertFile) (*tls.Config, error)andclient.WithTLSConfig(*tls.Config)option;newClientapplies them incmd/tpagectl/main.go.--insecurewarning goes to stderr so stdout stays scriptable.Closes #258
Closes #259
Closes #260
Closes #261
Thorough implementation of the TLS verification controls.
NewTLSConfighandles the none/insecure/custom-CA cases cleanly, the CA bundle is appended to the system pool, missing/empty bundles fail before any request, the warning goes to stderr, and the e2e tests (--insecureconnects and warns,--ca-certverifies, default rejects untrusted certs) prove the system-pool default. Approving; two follow-up suggestions filed.Suggestions
internal/tpagectl/client/client.go:60–WithTLSConfigreplaces the transport with a bare&http.Transport{}, droppinghttp.DefaultTransportbehavior:ProxyFromEnvironment(soHTTP_PROXY/HTTPS_PROXY/NO_PROXYare ignored whenever--insecureor--ca-certis set), default dial/handshake/idle timeouts, and HTTP/2. Clonehttp.DefaultTransportand setTLSClientConfigon the clone. Filed as #598.internal/tpagectl/client/client.go:145–NewTLSConfigreads and validates the CA bundle even wheninsecureis set, so--insecure --ca-cert <bad-path>errors out despite verification being disabled. Skip CA handling when insecure, or document the flags as mutually exclusive. Filed as #599.Question
--insecurewarning is printed wheneverInsecureis true, including when it comes from config/env — the message references(--insecure)which may mislead when the flag wasn't passed. Also, CA-file errors raised in the rootBeforehook abort all commands (same pattern noted in #596). Consider resolving TLS config lazily for commands that need it.