This commit is contained in:
6543 2023-02-10 16:42:29 +01:00
parent de175da42d
commit 008ce4ab02
3 changed files with 14 additions and 9 deletions

View file

@ -3,7 +3,6 @@ package database
import (
"errors"
"fmt"
"strings"
"github.com/rs/zerolog/log"
@ -77,8 +76,10 @@ func (x xDB) Put(domain string, cert *certificate.Resource) error {
}
func (x xDB) Get(domain string) (*certificate.Resource, error) {
// TODO: do we need this or can we just go with domain name for wildcard cert
domain = strings.TrimPrefix(domain, ".")
// handle wildcard certs
if domain[:1] == "." {
domain = "*" + domain
}
cert := new(Cert)
log.Trace().Str("domain", domain).Msg("get cert from db")
@ -91,6 +92,11 @@ func (x xDB) Get(domain string) (*certificate.Resource, error) {
}
func (x xDB) Delete(domain string) error {
// handle wildcard certs
if domain[:1] == "." {
domain = "*" + domain
}
log.Trace().Str("domain", domain).Msg("delete cert from db")
_, err := x.engine.ID(domain).Delete(new(Cert))
return err