diff --git a/agent/app/service/website_ssl.go b/agent/app/service/website_ssl.go index e8143e979..8a3ee6ac2 100644 --- a/agent/app/service/website_ssl.go +++ b/agent/app/service/website_ssl.go @@ -410,6 +410,19 @@ func (w WebsiteSSLService) Delete(ids []uint) error { return buserr.New("ErrDeleteWithPanelSSL") } } + websiteSSL, err := websiteSSLRepo.GetFirst(commonRepo.WithByID(id)) + if err != nil { + return err + } + acmeAccount, err := websiteAcmeRepo.GetFirst(commonRepo.WithByID(websiteSSL.AcmeAccountID)) + if err != nil { + return err + } + client, err := ssl.NewAcmeClient(acmeAccount) + if err != nil { + return err + } + _ = client.RevokeSSL([]byte(websiteSSL.Pem)) _ = websiteSSLRepo.DeleteBy(commonRepo.WithByID(id)) } if len(names) > 0 { diff --git a/agent/utils/ssl/client.go b/agent/utils/ssl/client.go index 4799684d3..2d4515e64 100644 --- a/agent/utils/ssl/client.go +++ b/agent/utils/ssl/client.go @@ -227,6 +227,10 @@ func (c *AcmeClient) ObtainSSL(domains []string, privateKey crypto.PrivateKey) ( return *certificates, nil } +func (c *AcmeClient) RevokeSSL(pemSSL []byte) error { + return c.Client.Certificate.Revoke(pemSSL) +} + type Resolve struct { Key string Value string