Add support for redirect https to https when from-to-www-redirect is defined
This commit is contained in:
parent
35f5a6ce1f
commit
a3bcbeb3d2
6 changed files with 196 additions and 31 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue