删除证书之前检查是否正在被NS集群使用

This commit is contained in:
刘祥超
2022-08-04 16:26:34 +08:00
parent dad8802fb0
commit f78daa98bc
3 changed files with 31 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
package certs package certs
import ( import (
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs" "github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
@@ -37,13 +38,27 @@ func (this *DeleteAction) RunPost(params struct {
} }
// 是否正在被用户节点使用 // 是否正在被用户节点使用
if teaconst.IsPlus {
countResp, err = this.RPC().UserNodeRPC().CountAllEnabledUserNodesWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledUserNodesWithSSLCertIdRequest{SslCertId: params.CertId}) countResp, err = this.RPC().UserNodeRPC().CountAllEnabledUserNodesWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledUserNodesWithSSLCertIdRequest{SslCertId: params.CertId})
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
if countResp.Count > 0 { if countResp.Count > 0 {
this.Fail("此证书正在被某些用户节点引用,请先修改用户节点后再删除") this.Fail("此证书正在被某些用户节点引用,请先修改相关用户节点后再删除")
}
}
// 是否正在被NS集群使用
if teaconst.IsPlus {
countResp, err = this.RPC().NSClusterRPC().CountAllNSClustersWithSSLCertId(this.AdminContext(), &pb.CountAllNSClustersWithSSLCertIdRequest{SslCertId: params.CertId})
if err != nil {
this.ErrorPage(err)
return
}
if countResp.Count > 0 {
this.Fail("此证书正在被某些DNS集群节点引用请先修改相关DNS集群设置后再删除")
}
} }
_, err = this.RPC().SSLCertRPC().DeleteSSLCert(this.AdminContext(), &pb.DeleteSSLCertRequest{SslCertId: params.CertId}) _, err = this.RPC().SSLCertRPC().DeleteSSLCert(this.AdminContext(), &pb.DeleteSSLCertRequest{SslCertId: params.CertId})

View File

@@ -30,7 +30,7 @@
<tr> <tr>
<td>域名</td> <td>域名</td>
<td> <td>
<span class="ui label small" v-for="dnsName in info.dnsNames">{{dnsName}}</span> <span class="ui label small basic" v-for="dnsName in info.dnsNames">{{dnsName}}</span>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -42,7 +42,7 @@
<td> <td>
<span class="disabled" v-if="servers.length == 0">暂时没有引用此证书的服务。</span> <span class="disabled" v-if="servers.length == 0">暂时没有引用此证书的服务。</span>
<div v-if="servers.length > 0"> <div v-if="servers.length > 0">
<a v-for="server in servers" :href="'/servers/server?serverId=' + server.id" target="_blank" class="ui label small">{{server.name}}</a> <a v-for="server in servers" :href="'/servers/server/settings/https?serverId=' + server.id" target="_blank" class="ui label small basic">{{server.name}}</a>
</div> </div>
</td> </td>
</tr> </tr>

View File

@@ -20,7 +20,6 @@
<thead> <thead>
<tr> <tr>
<th>证书说明</th> <th>证书说明</th>
<th v-if="viewSize == 'normal'">顶级发行组织</th>
<th>域名</th> <th>域名</th>
<th>过期日期</th> <th>过期日期</th>
<th v-if="viewSize == 'normal'">引用服务</th> <th v-if="viewSize == 'normal'">引用服务</th>
@@ -29,14 +28,18 @@
</tr> </tr>
</thead> </thead>
<tr v-for="(cert, index) in certs"> <tr v-for="(cert, index) in certs">
<td><keyword :v-word="keyword">{{cert.name}}</keyword> <td>
<a href="" @click.prevent="selectCert(cert)" v-if="!certInfos[index].isSelected"><keyword :v-word="keyword">{{cert.name}}</keyword></a>
<span v-if="certInfos[index].isSelected">{{cert.name}}</span>
<div v-if="cert.commonNames != null && cert.commonNames.length > 0" style="margin-top:0.5em">
<span class="grey small">{{cert.commonNames[cert.commonNames.length-1]}}</span>
</div>
<div v-if="cert.isCA" style="margin-top:0.5em"> <div v-if="cert.isCA" style="margin-top:0.5em">
<span class="ui label olive tiny">CA</span> <span class="ui label olive tiny">CA</span>
</div> </div>
</td> </td>
<td v-if="viewSize == 'normal'">
<span v-if="cert.commonNames != null && cert.commonNames.length > 0">{{cert.commonNames[cert.commonNames.length-1]}}</span>
</td>
<td> <td>
<div v-for="dnsName in cert.dnsNames" style="margin-bottom:0.4em"> <div v-for="dnsName in cert.dnsNames" style="margin-bottom:0.4em">
<span class="ui label tiny"><keyword :v-word="keyword">{{dnsName}}</keyword></span> <span class="ui label tiny"><keyword :v-word="keyword">{{dnsName}}</keyword></span>