From 9002db2ae03906fdbfd3ede2fc32825388889ee9 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 2 Dec 2015 12:40:57 -0700 Subject: [PATCH] letsencrypt: Remote duplicate hosts from certificate request Domain names must be unique in cert bundle request or really bad things happen (like, um, a panic) --- caddy/letsencrypt/letsencrypt.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/caddy/letsencrypt/letsencrypt.go b/caddy/letsencrypt/letsencrypt.go index 16312bd6a..feeac2975 100644 --- a/caddy/letsencrypt/letsencrypt.go +++ b/caddy/letsencrypt/letsencrypt.go @@ -79,9 +79,19 @@ func Activate(configs []server.Config) ([]server.Config, error) { } // little bit of housekeeping; gather the hostnames into a slice - hosts := make([]string, len(cfgIndexes)) - for i, idx := range cfgIndexes { - hosts[i] = configs[idx].Host + var hosts []string + for _, idx := range cfgIndexes { + // don't allow duplicates (happens when serving same host on multiple ports!) + var duplicate bool + for _, otherHost := range hosts { + if configs[idx].Host == otherHost { + duplicate = true + break + } + } + if !duplicate { + hosts = append(hosts, configs[idx].Host) + } } // client is ready, so let's get free, trusted SSL certificates!