|
@@ -110,8 +110,29 @@ func (m *Manager) DefaultCertExistsSep() (bool, bool) {
|
|
|
return utils.FileExists(filepath.Join(m.CertStore, "default.crt")), utils.FileExists(filepath.Join(m.CertStore, "default.key"))
|
|
|
}
|
|
|
|
|
|
+//Delete the cert if exists
|
|
|
+func (m *Manager) RemoveCert(domain string) error {
|
|
|
+ pubKey := filepath.Join(m.CertStore, domain+".crt")
|
|
|
+ priKey := filepath.Join(m.CertStore, domain+".key")
|
|
|
+ if utils.FileExists(pubKey) {
|
|
|
+ err := os.Remove(pubKey)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if utils.FileExists(priKey) {
|
|
|
+ err := os.Remove(priKey)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
//Check if the given file is a valid TLS file
|
|
|
-func isValidTLSFile(file io.Reader) bool {
|
|
|
+func IsValidTLSFile(file io.Reader) bool {
|
|
|
// Read the contents of the uploaded file
|
|
|
contents, err := io.ReadAll(file)
|
|
|
if err != nil {
|