fix(server): use tlsConfig nil-check to decide between Serve and ServeTLS#420
Open
mesaglio wants to merge 1 commit intocesanta:mainfrom
Open
fix(server): use tlsConfig nil-check to decide between Serve and ServeTLS#420mesaglio wants to merge 1 commit intocesanta:mainfrom
mesaglio wants to merge 1 commit intocesanta:mainfrom
Conversation
…eTLS When LetsEncrypt was configured, autocert.Manager set tlsConfig.GetCertificate but left CertFile and KeyFile empty. The previous condition checked for empty cert/key strings, which caused the server to call hs.Serve() (plain HTTP) instead of hs.ServeTLS(), silently ignoring the TLS configuration entirely. Replacing the condition with a tlsConfig == nil check ensures that any configured TLS path — whether via explicit cert files or LetsEncrypt — always results in ServeTLS being called. ServeTLS with empty certFile/keyFile is valid in Go and delegates certificate provisioning to GetCertificate.
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.
When LetsEncrypt was configured, autocert.Manager set tlsConfig.GetCertificate but left CertFile and KeyFile empty. The previous condition checked for empty cert/key strings, which caused the server to call hs.Serve() (plain HTTP) instead of hs.ServeTLS(), silently ignoring the TLS configuration entirely.
How to reproduce locally
mkdir -p /tmp/docker-auth-le-test/sslcache openssl req -x509 -newkey rsa:2048 \ -keyout /tmp/docker-auth-le-test/token.key \ -out /tmp/docker-auth-le-test/token.crt \ -days 1 -nodes -subj '/CN=localhost'/tmp/docker-auth-le-test/config-letsencrypt.yml:auth_server: