updated renewal date query
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Paul 2021-06-24 22:03:29 +02:00
parent 5615ae297a
commit 62af54fbb8

View File

@ -10,7 +10,6 @@ import (
"fmt" "fmt"
"log" "log"
"strings" "strings"
"time"
"git.paulbsd.com/paulbsd/pki/src/cert" "git.paulbsd.com/paulbsd/pki/src/cert"
"git.paulbsd.com/paulbsd/pki/src/config" "git.paulbsd.com/paulbsd/pki/src/config"
@ -31,10 +30,9 @@ func (u *User) Init(cfg *config.Config) (err error) {
// GetEntry returns requested acme ressource in database relative to domain // GetEntry returns requested acme ressource in database relative to domain
func (u *User) GetEntry(cfg *config.Config, domains []string) (Entry cert.Entry, err error) { func (u *User) GetEntry(cfg *config.Config, domains []string) (Entry cert.Entry, err error) {
renewaldate := time.Now().AddDate(0, 0, -cfg.ACME.MaxDaysBefore).Format("2006-01-02")
has, err := cfg.Db.Where("domains = ?", strings.Join(domains, ",")).Where( has, err := cfg.Db.Where("domains = ?", strings.Join(domains, ",")).Where(
"validity_end >= ?::timestamp", renewaldate).Where( "validity_end::timestamp-'? DAY'::INTERVAL >= now()", cfg.ACME.MaxDaysBefore).Where(
"auth_url = ?", cfg.ACME.AuthURL).Desc( "auth_url = ?", cfg.ACME.AuthURL).Desc(
"id").Get(&Entry) "id").Get(&Entry)