mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 14:20:55 +03:00
acme: use retryable client
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -44,6 +44,7 @@ import (
|
|||||||
"github.com/go-acme/lego/v4/log"
|
"github.com/go-acme/lego/v4/log"
|
||||||
"github.com/go-acme/lego/v4/providers/http/webroot"
|
"github.com/go-acme/lego/v4/providers/http/webroot"
|
||||||
"github.com/go-acme/lego/v4/registration"
|
"github.com/go-acme/lego/v4/registration"
|
||||||
|
"github.com/hashicorp/go-retryablehttp"
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
|
|
||||||
"github.com/drakkan/sftpgo/v2/internal/common"
|
"github.com/drakkan/sftpgo/v2/internal/common"
|
||||||
@@ -492,6 +493,13 @@ func (c *Configuration) setup() (*account, *lego.Client, error) {
|
|||||||
config.Certificate.KeyType = certcrypto.KeyType(c.KeyType)
|
config.Certificate.KeyType = certcrypto.KeyType(c.KeyType)
|
||||||
config.Certificate.OverallRequestLimit = 6
|
config.Certificate.OverallRequestLimit = 6
|
||||||
config.UserAgent = version.GetServerVersion("/", false)
|
config.UserAgent = version.GetServerVersion("/", false)
|
||||||
|
|
||||||
|
retryClient := retryablehttp.NewClient()
|
||||||
|
retryClient.RetryMax = 5
|
||||||
|
retryClient.HTTPClient = config.HTTPClient
|
||||||
|
|
||||||
|
config.HTTPClient = retryClient.StandardClient()
|
||||||
|
|
||||||
client, err := lego.NewClient(config)
|
client, err := lego.NewClient(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
acmeLog(logger.LevelError, "unable to get ACME client: %v", err)
|
acmeLog(logger.LevelError, "unable to get ACME client: %v", err)
|
||||||
@@ -559,6 +567,12 @@ func (c *Configuration) tryRecoverRegistration(privateKey crypto.PrivateKey) (*r
|
|||||||
config.CADirURL = c.CAEndpoint
|
config.CADirURL = c.CAEndpoint
|
||||||
config.UserAgent = version.GetServerVersion("/", false)
|
config.UserAgent = version.GetServerVersion("/", false)
|
||||||
|
|
||||||
|
retryClient := retryablehttp.NewClient()
|
||||||
|
retryClient.RetryMax = 5
|
||||||
|
retryClient.HTTPClient = config.HTTPClient
|
||||||
|
|
||||||
|
config.HTTPClient = retryClient.StandardClient()
|
||||||
|
|
||||||
client, err := lego.NewClient(config)
|
client, err := lego.NewClient(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
acmeLog(logger.LevelError, "unable to get the ACME client: %v", err)
|
acmeLog(logger.LevelError, "unable to get the ACME client: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user