AutoHTTPS - сайты
Исправил ошибка, когда был поддомен - не срабатывал автоматический AUTOhttps
This commit is contained in:
@@ -103,14 +103,29 @@ func Cert_start() {
|
||||
}
|
||||
|
||||
func checkHostCert(r *http.Request) bool {
|
||||
host := r.Host
|
||||
|
||||
if _, err := os.Stat(certDir + r.Host); err != nil {
|
||||
return false
|
||||
// Убираем порт если есть
|
||||
if colonIndex := strings.Index(host, ":"); colonIndex != -1 {
|
||||
host = host[:colonIndex]
|
||||
}
|
||||
|
||||
// Проверяем точное совпадение
|
||||
if _, err := os.Stat(certDir + host); err == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
// Проверяем родительский домен
|
||||
parentDomain := getParentDomain(host)
|
||||
if parentDomain != "" {
|
||||
if _, err := os.Stat(certDir + parentDomain); err == nil {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func loadCertificates(certDir string) map[string]*tls.Certificate {
|
||||
certMap := make(map[string]*tls.Certificate)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user