summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--modules/caddytls/matchers.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/caddytls/matchers.go b/modules/caddytls/matchers.go
index 83a464713..f94622374 100644
--- a/modules/caddytls/matchers.go
+++ b/modules/caddytls/matchers.go
@@ -50,12 +50,13 @@ func (MatchServerName) CaddyModule() caddy.ModuleInfo {
// Match matches hello based on SNI.
func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
+ repl := caddy.NewReplacer()
// caddytls.TestServerNameMatcher calls this function without any context
- var repl *caddy.Replacer
if ctx := hello.Context(); ctx != nil {
- repl = ctx.Value(caddy.ReplacerCtxKey).(*caddy.Replacer)
- } else {
- repl = caddy.NewReplacer()
+ // In some situations the existing context may have no replacer
+ if replAny := ctx.Value(caddy.ReplacerCtxKey); replAny != nil {
+ repl = replAny.(*caddy.Replacer)
+ }
}
for _, name := range m {