Append CA certificate to complete TLS chain in AutoCert plugin - #369
Merged
Conversation
Co-authored-by: drk1wi <2052966+drk1wi@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
drk1wi
August 14, 2026 13:19
View session
drk1wi
marked this pull request as ready for review
August 14, 2026 13:22
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>
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.
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/-certKeysupplied), append the CA certificate's PEM block after the leaf certificate's PEM block soconfig.C.TLSCertificatecontains 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 additionalpem.Encodecall appendingcatls.Certificate[0](the CA's DER bytes, already loaded in memory) to the certificate buffer.Scope / Safety
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.tls.X509KeyPaircorrectly parses the concatenated PEM blocks into an ordered[]bytechain ([leaf, ca]), matching Go's expected leaf-first certificate chain format.tls.Certificate.Certificate) has exactly one element.go build ./...,go vet ./..., andgo test ./...all pass.Testing
go build ./...— passesgo vet ./...— passesgo test ./...— passes (no existing tests coverplugin/autocert.go, none broken)