mirror of
https://github.com/go-acme/lego
synced 2026-03-14 14:35:48 +01:00
chore(ari): use doer instead of raw HTTP client
This commit is contained in:
parent
8c87524499
commit
833f100d6a
2 changed files with 4 additions and 18 deletions
|
|
@ -5,10 +5,8 @@ import (
|
|||
"crypto/x509"
|
||||
"encoding/asn1"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-acme/lego/v5/acme"
|
||||
)
|
||||
|
|
@ -32,25 +30,15 @@ func (c *CertificateService) GetRenewalInfo(ctx context.Context, certID string)
|
|||
return nil, errors.New("renewalInfo[get]: 'certID' cannot be empty")
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.core.GetDirectory().RenewalInfo+"/"+certID, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
info := new(acme.ExtendedRenewalInfo)
|
||||
|
||||
resp, err := c.core.HTTPClient.Do(req)
|
||||
resp, err := c.core.doer.Get(ctx, c.core.GetDirectory().RenewalInfo+"/"+certID, info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
info := new(acme.ExtendedRenewalInfo)
|
||||
|
||||
err = json.NewDecoder(resp.Body).Decode(info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if retry := resp.Header.Get("Retry-After"); retry != "" {
|
||||
info.RetryAfter, err = ParseRetryAfter(retry)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -50,8 +50,7 @@ func TestCertificateService_GetRenewalInfo(t *testing.T) {
|
|||
"end": "2020-03-17T18:21:09Z"
|
||||
},
|
||||
"explanationUrl": "https://aricapable.ca.example/docs/renewal-advice/"
|
||||
}
|
||||
}`).
|
||||
}`).
|
||||
WithHeader("Content-Type", "application/json").
|
||||
WithHeader("Retry-After", "21600")).
|
||||
BuildHTTPS(t)
|
||||
|
|
@ -83,8 +82,7 @@ func TestCertificateService_GetRenewalInfo_retryAfter(t *testing.T) {
|
|||
"end": "2020-03-17T18:21:09Z"
|
||||
},
|
||||
"explanationUrl": "https://aricapable.ca.example/docs/renewal-advice/"
|
||||
}
|
||||
}`).
|
||||
}`).
|
||||
WithHeader("Content-Type", "application/json").
|
||||
WithHeader("Retry-After", time.Now().UTC().Add(6*time.Hour).Format(time.RFC1123))).
|
||||
BuildHTTPS(t)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue