mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-02 03:40:27 +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()
|
||||
}
|
||||
|
||||
|
||||
@@ -415,7 +415,7 @@ Vue.component("ssl-config-box", {
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">选择证书</td>
|
||||
<td class="title">设置证书</td>
|
||||
<td>
|
||||
<div v-if="policy.certs != null && policy.certs.length > 0">
|
||||
<div class="ui label small basic" v-for="(cert, index) in policy.certs" style="margin-top: 0.2em">
|
||||
|
||||
@@ -9,7 +9,12 @@
|
||||
{$template "/left_menu_with_menu"}
|
||||
|
||||
<div class="right-box with-menu">
|
||||
<p class="comment">提醒:HTTP2、证书等信息修改后,可能需要清空浏览器缓存后才能浏览效果。</p>
|
||||
<p class="comment">提醒:HTTP/2、证书等信息修改后,可能需要清空浏览器缓存后才能浏览效果。</p>
|
||||
|
||||
<div v-if="httpsConfig.isOn && missingCertServerNames.length > 0" class="ui message warning">
|
||||
警告:当前网站绑定的以下域名尚未配置证书,将无法通过HTTPS协议访问:{{missingCertServerNames.join("、")}} 。
|
||||
</div>
|
||||
|
||||
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<input type="hidden" name="serverId" :value="serverId"/>
|
||||
<input type="hidden" name="serverType" :value="serverType"/>
|
||||
|
||||
Reference in New Issue
Block a user