Validate config input before starting first acme
This commit is contained in:
16
acme/acme.go
16
acme/acme.go
@@ -32,6 +32,13 @@ type Acme struct {
|
||||
|
||||
func SetupAcme(config *domainrouter.Config) (*Acme, error) {
|
||||
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
|
||||
if _, err := os.Stat(acme.KeyFile); errors.Is(err, os.ErrNotExist) {
|
||||
privateKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||
@@ -109,11 +116,6 @@ func SetupAcme(config *domainrouter.Config) (*Acme, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
d, err := time.ParseDuration(acme.RenewTime)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Acme{
|
||||
user: &user,
|
||||
client: client,
|
||||
@@ -150,12 +152,10 @@ func (a *Acme) RenewAcme() error {
|
||||
|
||||
func (a *Acme) RegisterTicker() {
|
||||
for {
|
||||
select {
|
||||
case <-a.renewTicker.C:
|
||||
<-a.renewTicker.C
|
||||
a.RenewAcme()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func encodePrivKey(privateKey *ecdsa.PrivateKey) string {
|
||||
x509Encoded, _ := x509.MarshalECPrivateKey(privateKey)
|
||||
|
||||
Reference in New Issue
Block a user