Validate config input before starting first acme
This commit is contained in:
18
acme/acme.go
18
acme/acme.go
@@ -32,6 +32,13 @@ type Acme struct {
|
|||||||
|
|
||||||
func SetupAcme(config *domainrouter.Config) (*Acme, error) {
|
func SetupAcme(config *domainrouter.Config) (*Acme, error) {
|
||||||
acme := config.Server.Ssl.Acme
|
acme := config.Server.Ssl.Acme
|
||||||
|
|
||||||
|
d, err := time.ParseDuration(acme.RenewTime)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maybe this should be reconsidered, to create a new private Key / account per Acme request
|
||||||
var privateKey *ecdsa.PrivateKey
|
var privateKey *ecdsa.PrivateKey
|
||||||
if _, err := os.Stat(acme.KeyFile); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(acme.KeyFile); errors.Is(err, os.ErrNotExist) {
|
||||||
privateKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
privateKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||||
@@ -109,11 +116,6 @@ func SetupAcme(config *domainrouter.Config) (*Acme, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
d, err := time.ParseDuration(acme.RenewTime)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Acme{
|
return &Acme{
|
||||||
user: &user,
|
user: &user,
|
||||||
client: client,
|
client: client,
|
||||||
@@ -150,10 +152,8 @@ func (a *Acme) RenewAcme() error {
|
|||||||
|
|
||||||
func (a *Acme) RegisterTicker() {
|
func (a *Acme) RegisterTicker() {
|
||||||
for {
|
for {
|
||||||
select {
|
<-a.renewTicker.C
|
||||||
case <-a.renewTicker.C:
|
a.RenewAcme()
|
||||||
a.RenewAcme()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user