2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-05 08:07:17 +08:00

fix(ssl): read cert

This commit is contained in:
耗子
2023-07-27 16:06:45 +08:00
parent 5b83e042c2
commit 8fec8af0d7

View File

@@ -313,21 +313,13 @@ func (r *WebsiteImpl) GetConfig(id int) (WebsiteSetting, error) {
setting.OpenBasedir = false
}
setting.SslCertificate = tools.ReadFile("/www/server/vhost/ssl/" + website.Name + ".pem")
setting.SslCertificateKey = tools.ReadFile("/www/server/vhost/ssl/" + website.Name + ".key")
if setting.Ssl {
ssl := tools.Cut(config, "# ssl标记位开始", "# ssl标记位结束")
match = regexp.MustCompile(`ssl_certificate\s+(.*);`).FindStringSubmatch(ssl)
if len(match) > 1 {
setting.SslCertificate = tools.ReadFile(match[1])
}
match = regexp.MustCompile(`ssl_certificate_key\s+(.*);`).FindStringSubmatch(ssl)
if len(match) > 1 {
setting.SslCertificateKey = tools.ReadFile(match[1])
}
setting.HttpRedirect = strings.Contains(ssl, "# http重定向标记位")
setting.Hsts = strings.Contains(ssl, "# hsts标记位")
} else {
setting.SslCertificate = ""
setting.SslCertificateKey = ""
setting.HttpRedirect = false
setting.Hsts = false
}