Skip to content

Append CA certificate to complete TLS chain in AutoCert plugin - #369

Merged
drk1wi merged 3 commits into
masterfrom
copilot/fix-session-issues
Aug 14, 2026
Merged

Append CA certificate to complete TLS chain in AutoCert plugin#369
drk1wi merged 3 commits into
masterfrom
copilot/fix-session-issues

Conversation

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Applies the fix proposed in #362 (closed without merge): when the AutoCert plugin auto-generates a self-signed TLS certificate (i.e. no -cert/-certKey supplied), append the CA certificate's PEM block after the leaf certificate's PEM block so config.C.TLSCertificate contains a complete leaf+CA chain.

Why

Some TLS clients fail to build/verify the certificate chain locally and report a "TLS handshake error" when only the leaf certificate is served without the CA. Serving the full chain (leaf + CA) is standard practice and resolves this for those clients.

Change

  • plugin/autocert.go: one additional pem.Encode call appending catls.Certificate[0] (the CA's DER bytes, already loaded in memory) to the certificate buffer.

Scope / Safety

  • Only affects the AutoCert code path, gated by if *config.C.ForceHTTP == false && len(*config.C.TLSCertificate) == 0 && len(*config.C.TLSKey) == 0. Users supplying their own certificate/key, or running with -forceHttp, are unaffected — this branch is skipped entirely for them.
  • Verified with a standalone Go reproduction that tls.X509KeyPair correctly parses the concatenated PEM blocks into an ordered []byte chain ([leaf, ca]), matching Go's expected leaf-first certificate chain format.
  • No code in the repo assumes the certificate chain slice (tls.Certificate.Certificate) has exactly one element.
  • go build ./..., go vet ./..., and go test ./... all pass.
  • No secrets introduced (scanned changed file).

Testing

  • go build ./... — passes
  • go vet ./... — passes
  • go test ./... — passes (no existing tests cover plugin/autocert.go, none broken)

Co-authored-by: drk1wi <2052966+drk1wi@users.noreply.github.com>
Copilot AI and others added 2 commits August 14, 2026 13:25
Co-authored-by: drk1wi <2052966+drk1wi@users.noreply.github.com>
Co-authored-by: standerksen <8461154+standerksen@users.noreply.github.com>

Co-authored-by: drk1wi <2052966+drk1wi@users.noreply.github.com>
@drk1wi
drk1wi merged commit c4207b1 into master Aug 14, 2026
1 check passed
@drk1wi
drk1wi deleted the copilot/fix-session-issues branch August 14, 2026 14:06
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.

2 participants