Skip to content

Commit

Permalink
fix: client - delete certificat only if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
fgouteroux committed Jan 31, 2025
1 parent 83be15b commit f97ea14
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,14 @@ func createLocalCertificateResource(certData certstore.CertMap, logger log.Logge

func deleteLocalCertificateResource(certData certstore.CertMap, logger log.Logger) {
certFilePath := config.Common.CertDir + certData.Issuer + "/" + certData.Domain + config.Common.CertFileExt

err := os.Remove(certFilePath)
if err != nil {
_ = level.Error(logger).Log("msg", fmt.Sprintf("Unable to delete certificate file %s", certFilePath), "err", err)
} else {
_ = level.Info(logger).Log("msg", fmt.Sprintf("Removed certificate %s", certFilePath))
metrics.IncDeletedLocalCertificate(certData.Issuer)
if utils.FileExists((certFilePath){
err := os.Remove(certFilePath)
if err != nil {
_ = level.Error(logger).Log("msg", fmt.Sprintf("Unable to delete certificate file %s", certFilePath), "err", err)
} else {
_ = level.Info(logger).Log("msg", fmt.Sprintf("Removed certificate %s", certFilePath))
metrics.IncDeletedLocalCertificate(certData.Issuer)
}
}
}

Expand Down

0 comments on commit f97ea14

Please sign in to comment.