Add support for redirect https to https when from-to-www-redirect is defined

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-01-09 00:33:16 -03:00
parent 35f5a6ce1f
commit a3bcbeb3d2
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
6 changed files with 196 additions and 31 deletions

View file

@ -30,6 +30,7 @@ import (
"math/big"
"net"
"strconv"
"strings"
"time"
"github.com/zakjan/cert-chain-resolver/certUtil"
@ -508,3 +509,21 @@ func FullChainCert(in string, fs file.Filesystem) ([]byte, error) {
return certUtil.EncodeCertificates(certs), nil
}
// IsValidHostname checks if a hostname is valid in a list of common names
func IsValidHostname(hostname string, commonNames []string) bool {
for _, cn := range commonNames {
if strings.EqualFold(hostname, cn) {
return true
}
labels := strings.Split(hostname, ".")
labels[0] = "*"
candidate := strings.Join(labels, ".")
if strings.EqualFold(candidate, cn) {
return true
}
}
return false
}