mirror of
https://github.com/yusing/godoxy.git
synced 2026-02-24 09:44:58 +01:00
29 lines
554 B
Go
29 lines
554 B
Go
package autocert
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
strutils "github.com/yusing/goutils/strings"
|
|
)
|
|
|
|
func (p *Provider) Setup() (err error) {
|
|
if err = p.LoadCert(); err != nil {
|
|
if !errors.Is(err, os.ErrNotExist) { // ignore if cert doesn't exist
|
|
return err
|
|
}
|
|
log.Debug().Msg("obtaining cert due to error loading cert")
|
|
if err = p.ObtainCert(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
for _, expiry := range p.GetExpiries() {
|
|
log.Info().Msg("certificate expire on " + strutils.FormatTime(expiry))
|
|
break
|
|
}
|
|
|
|
return nil
|
|
}
|