mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
29 lines
592 B
Go
29 lines
592 B
Go
package autocert
|
|
|
|
import (
|
|
"os"
|
|
|
|
E "github.com/yusing/go-proxy/internal/error"
|
|
"github.com/yusing/go-proxy/internal/utils/strutils"
|
|
)
|
|
|
|
func (p *Provider) Setup() (err E.Error) {
|
|
if err = p.LoadCert(); err != nil {
|
|
if !err.Is(os.ErrNotExist) { // ignore if cert doesn't exist
|
|
return err
|
|
}
|
|
logger.Debug().Msg("obtaining cert due to error loading cert")
|
|
if err = p.ObtainCert(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
p.ScheduleRenewal()
|
|
|
|
for _, expiry := range p.GetExpiries() {
|
|
logger.Info().Msg("certificate expire on " + strutils.FormatTime(expiry))
|
|
break
|
|
}
|
|
|
|
return nil
|
|
}
|