This commit is contained in:
parent
69e0a6d3f4
commit
90650aacfa
@ -9,6 +9,7 @@ import (
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"git.paulbsd.com/paulbsd/pki/src/cert"
|
||||
"git.paulbsd.com/paulbsd/pki/src/config"
|
||||
@ -29,7 +30,13 @@ func (u *User) Init(cfg *config.Config) (err error) {
|
||||
|
||||
// GetEntry returns requested acme ressource in database relative to domain
|
||||
func (u *User) GetEntry(cfg *config.Config, domain string) (Entry cert.Entry, err error) {
|
||||
has, err := cfg.Db.Where("domain = ?", domain).Get(&Entry)
|
||||
todaydate := time.Now().Format("2006-01-02")
|
||||
requireddate := time.Now().AddDate(0, 0, -cfg.ACME.MaxDaysBefore).Format("2006-01-02")
|
||||
|
||||
has, err := cfg.Db.Where("domain = ?", domain).Where(
|
||||
"validity_begin < ?::date", todaydate).Where(
|
||||
"validity_end > ?::date", requireddate).Where(
|
||||
"auth_url = ?", cfg.ACME.AuthURL).Get(&Entry)
|
||||
if !has {
|
||||
err = fmt.Errorf("Entry doesn't exists")
|
||||
}
|
||||
|
@ -69,11 +69,6 @@ func GetDates(cert []byte) (NotBefore time.Time, NotAfter time.Time, err error)
|
||||
return
|
||||
}
|
||||
|
||||
// NeedRenewal is an unimplemented method
|
||||
func NeedRenewal(cfg config.Config) (res bool, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// convertEntryToResponse converts database ACME entry to JSON ACME entry
|
||||
func convertEntryToResponse(in cert.Entry) (out EntryResponse) {
|
||||
out.Domain = in.Domain
|
||||
|
Loading…
Reference in New Issue
Block a user