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

This commit is contained in:
GoEdgeLab
2022-08-04 16:26:34 +08:00
parent 676b80a6f8
commit cb8207203a
3 changed files with 31 additions and 13 deletions

View File

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