mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-02 20:00:26 +08:00
在HTTPS页面提示用户没有设置证书的域名
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
@@ -71,6 +72,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.Data["conflictingPorts"] = conflictingPorts
|
||||
|
||||
var sslPolicy *sslconfigs.SSLPolicy
|
||||
var allDNSNames []string
|
||||
if httpsConfig.SSLPolicyRef != nil && httpsConfig.SSLPolicyRef.SSLPolicyId > 0 {
|
||||
sslPolicyConfigResp, err := this.RPC().SSLPolicyRPC().FindEnabledSSLPolicyConfig(this.AdminContext(), &pb.FindEnabledSSLPolicyConfigRequest{
|
||||
SslPolicyId: httpsConfig.SSLPolicyRef.SSLPolicyId,
|
||||
@@ -88,6 +90,14 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, cert := range sslPolicy.Certs {
|
||||
for _, dnsName := range cert.DNSNames {
|
||||
if !lists.ContainsString(allDNSNames, dnsName) {
|
||||
allDNSNames = append(allDNSNames, dnsName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +120,36 @@ func (this *IndexAction) RunGet(params struct {
|
||||
"supportsHTTP3": supportsHTTP3,
|
||||
}
|
||||
|
||||
// 检查域名是否都已经上传了证书
|
||||
serverNamesResp, err := this.RPC().ServerRPC().FindServerNames(this.AdminContext(), &pb.FindServerNamesRequest{
|
||||
ServerId: server.Id,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var allServerNames []string
|
||||
if len(serverNamesResp.ServerNamesJSON) > 0 {
|
||||
var serverNamesConfigs = []*serverconfigs.ServerNameConfig{}
|
||||
err = json.Unmarshal(serverNamesResp.ServerNamesJSON, &serverNamesConfigs)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
allServerNames = serverconfigs.PlainServerNames(serverNamesConfigs)
|
||||
}
|
||||
|
||||
this.Data["missingCertServerNames"] = []string{}
|
||||
if len(allServerNames) > 0 {
|
||||
var missingServerNames []string
|
||||
for _, serverName := range allServerNames {
|
||||
if !configutils.MatchDomains(allDNSNames, serverName) {
|
||||
missingServerNames = append(missingServerNames, serverName)
|
||||
}
|
||||
}
|
||||
this.Data["missingCertServerNames"] = missingServerNames
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user