From b59cd1e613b85d41a02cb703f578ead09a579e6c Mon Sep 17 00:00:00 2001 From: Antonio Mika Date: Tue, 28 May 2024 10:55:45 -0400 Subject: [PATCH] Allow on demand cert creation for root domain. Closes #287. --- httpmuxer/httpmuxer.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/httpmuxer/httpmuxer.go b/httpmuxer/httpmuxer.go index a6d5e0a..e6cd214 100644 --- a/httpmuxer/httpmuxer.go +++ b/httpmuxer/httpmuxer.go @@ -365,16 +365,18 @@ func Start(state *utils.State) { return fmt.Errorf("ondemand certificate retrieval is not enabled") } - ok := false + ok := name == viper.GetString("domain") - state.HTTPListeners.Range(func(key string, locationListener *utils.HTTPHolder) bool { - if name == locationListener.HTTPUrl.Host || utils.MatchesWildcardHost(name, locationListener.HTTPUrl.Host) { - ok = true - return false - } + if !ok { + state.HTTPListeners.Range(func(key string, locationListener *utils.HTTPHolder) bool { + if name == locationListener.HTTPUrl.Host || utils.MatchesWildcardHost(name, locationListener.HTTPUrl.Host) { + ok = true + return false + } - return true - }) + return true + }) + } if !ok { return fmt.Errorf("cannot find connection for host: %s", name)