forked from TrueCloudLab/lego
chore: update linter. (#1278)
This commit is contained in:
parent
dfc346a00b
commit
38f23c8c52
19 changed files with 61 additions and 53 deletions
|
@ -38,7 +38,10 @@
|
||||||
"nestif", # too many false-positive
|
"nestif", # too many false-positive
|
||||||
"goerr113", # not relevant
|
"goerr113", # not relevant
|
||||||
"noctx",
|
"noctx",
|
||||||
"nlreturn",
|
"nlreturn", # not relevant
|
||||||
|
"wrapcheck",
|
||||||
|
"tparallel", # not relevant
|
||||||
|
"exhaustivestruct", # too many false-positive
|
||||||
]
|
]
|
||||||
|
|
||||||
[issues]
|
[issues]
|
||||||
|
@ -63,13 +66,13 @@
|
||||||
text = "string `(bar|foo)` has (\\d+) occurrences, make it a constant"
|
text = "string `(bar|foo)` has (\\d+) occurrences, make it a constant"
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "certcrypto/crypto.go"
|
path = "certcrypto/crypto.go"
|
||||||
text = "`(tlsFeatureExtensionOID|ocspMustStapleFeature)` is a global variable"
|
text = "(tlsFeatureExtensionOID|ocspMustStapleFeature) is a global variable"
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "challenge/dns01/nameserver.go"
|
path = "challenge/dns01/nameserver.go"
|
||||||
text = "`(defaultNameservers|recursiveNameservers|dnsTimeout|fqdnSoaCache|muFqdnSoaCache)` is a global variable"
|
text = "(defaultNameservers|recursiveNameservers|dnsTimeout|fqdnSoaCache|muFqdnSoaCache) is a global variable"
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "challenge/dns01/nameserver_test.go"
|
path = "challenge/dns01/nameserver_test.go"
|
||||||
text = "`findXByFqdnTestCases` is a global variable"
|
text = "findXByFqdnTestCases is a global variable"
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "challenge/http01/domain_matcher.go"
|
path = "challenge/http01/domain_matcher.go"
|
||||||
text = "string `Host` has \\d occurrences, make it a constant"
|
text = "string `Host` has \\d occurrences, make it a constant"
|
||||||
|
@ -81,28 +84,25 @@
|
||||||
text = "Function 'parseForwardedHeader' has too many statements"
|
text = "Function 'parseForwardedHeader' has too many statements"
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "challenge/tlsalpn01/tls_alpn_challenge.go"
|
path = "challenge/tlsalpn01/tls_alpn_challenge.go"
|
||||||
text = "`idPeAcmeIdentifierV1` is a global variable"
|
text = "idPeAcmeIdentifierV1 is a global variable"
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "log/logger.go"
|
path = "log/logger.go"
|
||||||
text = "`Logger` is a global variable"
|
text = "Logger is a global variable"
|
||||||
[[issues.exclude-rules]]
|
|
||||||
path = "cmd/lego/main.go"
|
|
||||||
text = "`version` is a global variable"
|
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "e2e/(dnschallenge/)?[\\d\\w]+_test.go"
|
path = "e2e/(dnschallenge/)?[\\d\\w]+_test.go"
|
||||||
text = "`load` is a global variable"
|
text = "load is a global variable"
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "providers/dns/([\\d\\w]+/)*[\\d\\w]+_test.go"
|
path = "providers/dns/([\\d\\w]+/)*[\\d\\w]+_test.go"
|
||||||
text = "`envTest` is a global variable"
|
text = "envTest is a global variable"
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "providers/dns/namecheap/namecheap_test.go"
|
path = "providers/dns/namecheap/namecheap_test.go"
|
||||||
text = "`testCases` is a global variable"
|
text = "testCases is a global variable"
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "providers/dns/acmedns/acmedns_test.go"
|
path = "providers/dns/acmedns/acmedns_test.go"
|
||||||
text = "`(errorClientErr|errorStorageErr|egTestAccount)` is a global variable"
|
text = "egTestAccount is a global variable"
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "providers/http/memcached/memcached_test.go"
|
path = "providers/http/memcached/memcached_test.go"
|
||||||
text = "`memcachedHosts` is a global variable"
|
text = "memcachedHosts is a global variable"
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "providers/dns/sakuracloud/client_test.go"
|
path = "providers/dns/sakuracloud/client_test.go"
|
||||||
text = "cyclomatic complexity 13 of func `(TestDNSProvider_cleanupTXTRecord_concurrent|TestDNSProvider_addTXTRecord_concurrent)` is high"
|
text = "cyclomatic complexity 13 of func `(TestDNSProvider_cleanupTXTRecord_concurrent|TestDNSProvider_addTXTRecord_concurrent)` is high"
|
||||||
|
|
|
@ -8,6 +8,7 @@ Let's Encrypt client and ACME library written in Go.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
- ACME v2 [RFC 8555](https://tools.ietf.org/html/rfc8555)
|
||||||
- Register with CA
|
- Register with CA
|
||||||
- Obtain certificates, both from scratch or with an existing CSR
|
- Obtain certificates, both from scratch or with an existing CSR
|
||||||
- Renew certificates
|
- Renew certificates
|
||||||
|
|
|
@ -38,6 +38,7 @@ func (a *AccountService) NewEAB(accMsg acme.Account, kid, hmacEncoded string) (a
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return acme.ExtendedAccount{}, fmt.Errorf("acme: error signing eab content: %w", err)
|
return acme.ExtendedAccount{}, fmt.Errorf("acme: error signing eab content: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
accMsg.ExternalAccountBinding = eabJWS
|
accMsg.ExternalAccountBinding = eabJWS
|
||||||
|
|
||||||
return a.New(accMsg)
|
return a.New(accMsg)
|
||||||
|
|
|
@ -90,14 +90,14 @@ func (a *Core) retrievablePost(uri string, content []byte, response interface{})
|
||||||
var err error
|
var err error
|
||||||
resp, err = a.signedPost(uri, content, response)
|
resp, err = a.signedPost(uri, content, response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch err.(type) {
|
|
||||||
// Retry if the nonce was invalidated
|
// Retry if the nonce was invalidated
|
||||||
case *acme.NonceError:
|
var e *acme.NonceError
|
||||||
return err
|
if errors.As(err, &e) {
|
||||||
default:
|
|
||||||
cancel()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cancel()
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -109,7 +109,7 @@ func (a *Core) retrievablePost(uri string, content []byte, response interface{})
|
||||||
|
|
||||||
err := backoff.RetryNotify(operation, backoff.WithContext(bo, ctx), notify)
|
err := backoff.RetryNotify(operation, backoff.WithContext(bo, ctx), notify)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
|
|
@ -2,6 +2,7 @@ package tlsalpn01
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -87,7 +88,7 @@ func (s *ProviderServer) CleanUp(domain, token, keyAuth string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server was created, close it.
|
// Server was created, close it.
|
||||||
if err := s.listener.Close(); err != nil && err != http.ErrServerClosed {
|
if err := s.listener.Close(); err != nil && errors.Is(err, http.ErrServerClosed) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ func launchHook(hook string, meta map[string]string) error {
|
||||||
fmt.Println(string(output))
|
fmt.Println(string(output))
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctxCmd.Err() == context.DeadlineExceeded {
|
if errors.Is(ctxCmd.Err(), context.DeadlineExceeded) {
|
||||||
return errors.New("hook timed out")
|
return errors.New("hook timed out")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,10 +109,10 @@ func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
||||||
// Check if credentials were previously saved for this domain.
|
// Check if credentials were previously saved for this domain.
|
||||||
account, err := d.storage.Fetch(domain)
|
account, err := d.storage.Fetch(domain)
|
||||||
// Errors other than goacmeDNS.ErrDomainNotFound are unexpected.
|
// Errors other than goacmeDNS.ErrDomainNotFound are unexpected.
|
||||||
if err != nil && err != goacmedns.ErrDomainNotFound {
|
if err != nil && !errors.Is(err, goacmedns.ErrDomainNotFound) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err == goacmedns.ErrDomainNotFound {
|
if errors.Is(err, goacmedns.ErrDomainNotFound) {
|
||||||
// The account did not exist. Create a new one and return an error
|
// The account did not exist. Create a new one and return an error
|
||||||
// indicating the required one-time manual CNAME setup.
|
// indicating the required one-time manual CNAME setup.
|
||||||
return d.register(domain, fqdn)
|
return d.register(domain, fqdn)
|
||||||
|
|
|
@ -182,8 +182,8 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
// Get existing record set
|
// Get existing record set
|
||||||
rset, err := rsc.Get(ctx, d.config.ResourceGroup, zone, relative, dns.TXT)
|
rset, err := rsc.Get(ctx, d.config.ResourceGroup, zone, relative, dns.TXT)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
detailedError, ok := err.(autorest.DetailedError)
|
var detailed *autorest.DetailedError
|
||||||
if !ok || detailedError.StatusCode != http.StatusNotFound {
|
if !errors.As(err, detailed) || detailed.StatusCode != http.StatusNotFound {
|
||||||
return fmt.Errorf("azure: %w", err)
|
return fmt.Errorf("azure: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ func getAuthorizer(config *Config) (autorest.Authorizer, error) {
|
||||||
|
|
||||||
spToken, err := credentialsConfig.ServicePrincipalToken()
|
spToken, err := credentialsConfig.ServicePrincipalToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get oauth token from client credentials: %v", err)
|
return nil, fmt.Errorf("failed to get oauth token from client credentials: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
spToken.SetSender(config.HTTPClient)
|
spToken.SetSender(config.HTTPClient)
|
||||||
|
|
|
@ -77,6 +77,7 @@ func NewDNSProvider() (*DNSProvider, error) {
|
||||||
[]string{"CLOUDFLARE_ZONE_API_TOKEN", "CF_ZONE_API_TOKEN", "CLOUDFLARE_DNS_API_TOKEN", "CF_DNS_API_TOKEN"},
|
[]string{"CLOUDFLARE_ZONE_API_TOKEN", "CF_ZONE_API_TOKEN", "CLOUDFLARE_DNS_API_TOKEN", "CF_DNS_API_TOKEN"},
|
||||||
)
|
)
|
||||||
if errT != nil {
|
if errT != nil {
|
||||||
|
// nolint:errorlint
|
||||||
return nil, fmt.Errorf("cloudflare: %v or %v", err, errT)
|
return nil, fmt.Errorf("cloudflare: %v or %v", err, errT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,6 +223,6 @@ func isNotFound(err error) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
e, ok := err.(configdns.ConfigDNSError)
|
var e configdns.ConfigDNSError
|
||||||
return ok && e.NotFound()
|
return errors.As(err, &e) && e.NotFound()
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,11 +241,10 @@ func (d *DNSProvider) applyChanges(zone string, change *dns.Change) error {
|
||||||
|
|
||||||
chg, err := d.client.Changes.Create(d.config.Project, zone, change).Do()
|
chg, err := d.client.Changes.Create(d.config.Project, zone, change).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if v, ok := err.(*googleapi.Error); ok {
|
var v *googleapi.Error
|
||||||
if v.Code == http.StatusNotFound {
|
if errors.As(err, &v) && v.Code == http.StatusNotFound {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
data, _ := json.Marshal(change)
|
data, _ := json.Marshal(change)
|
||||||
return fmt.Errorf("failed to perform changes [zone %s, change %s]: %w", zone, string(data), err)
|
return fmt.Errorf("failed to perform changes [zone %s, change %s]: %w", zone, string(data), err)
|
||||||
|
|
|
@ -126,15 +126,15 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
|
|
||||||
_, err = d.client.Nameservers.CreateRecord(request)
|
_, err = d.client.Nameservers.CreateRecord(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch er := err.(type) {
|
var er *goinwx.ErrorResponse
|
||||||
case *goinwx.ErrorResponse:
|
if errors.As(err, &er) {
|
||||||
if er.Message == "Object exists" {
|
if er.Message == "Object exists" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("inwx: %w", err)
|
return fmt.Errorf("inwx: %w", err)
|
||||||
default:
|
|
||||||
return fmt.Errorf("inwx: %w", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("inwx: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -26,6 +26,7 @@ func newDmapiProvider() (*dmapiProvider, error) {
|
||||||
var errU error
|
var errU error
|
||||||
values, errU = env.Get(EnvUsername, EnvPassword)
|
values, errU = env.Get(EnvUsername, EnvPassword)
|
||||||
if errU != nil {
|
if errU != nil {
|
||||||
|
// nolint:errorlint
|
||||||
return nil, fmt.Errorf("joker: %v or %v", errU, err)
|
return nil, fmt.Errorf("joker: %v or %v", errU, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ type svcProvider struct {
|
||||||
func newSvcProvider() (*svcProvider, error) {
|
func newSvcProvider() (*svcProvider, error) {
|
||||||
values, err := env.Get(EnvUsername, EnvPassword)
|
values, err := env.Get(EnvUsername, EnvPassword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("joker: %v", err)
|
return nil, fmt.Errorf("joker: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
config := NewDefaultConfig()
|
config := NewDefaultConfig()
|
||||||
|
|
|
@ -95,7 +95,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
record, _, err := d.client.Records.Get(zone.Zone, dns01.UnFqdn(fqdn), "TXT")
|
record, _, err := d.client.Records.Get(zone.Zone, dns01.UnFqdn(fqdn), "TXT")
|
||||||
|
|
||||||
// Create a new record
|
// Create a new record
|
||||||
if err == rest.ErrRecordMissing || record == nil {
|
if errors.Is(err, rest.ErrRecordMissing) || record == nil {
|
||||||
log.Infof("Create a new record for [zone: %s, fqdn: %s, domain: %s]", zone.Zone, fqdn, domain)
|
log.Infof("Create a new record for [zone: %s, fqdn: %s, domain: %s]", zone.Zone, fqdn, domain)
|
||||||
|
|
||||||
record = dns.NewRecord(zone.Zone, dns01.UnFqdn(fqdn), "TXT")
|
record = dns.NewRecord(zone.Zone, dns01.UnFqdn(fqdn), "TXT")
|
||||||
|
|
|
@ -2,6 +2,7 @@ package pdns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -172,7 +173,7 @@ func (d *DNSProvider) sendRequest(method, uri string, body io.Reader) (json.RawM
|
||||||
var msg json.RawMessage
|
var msg json.RawMessage
|
||||||
err = json.NewDecoder(resp.Body).Decode(&msg)
|
err = json.NewDecoder(resp.Body).Decode(&msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if errors.Is(err, io.EOF) {
|
||||||
// empty body
|
// empty body
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package sakuracloud
|
package sakuracloud
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -70,9 +71,11 @@ func (d *DNSProvider) getHostedZone(domain string) (*sacloud.DNS, error) {
|
||||||
|
|
||||||
res, err := d.client.Reset().WithNameLike(zoneName).Find()
|
res, err := d.client.Reset().WithNameLike(zoneName).Find()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if notFound, ok := err.(api.Error); ok && notFound.ResponseCode() == http.StatusNotFound {
|
var notFound api.Error
|
||||||
|
if errors.As(err, ¬Found) && notFound.ResponseCode() == http.StatusNotFound {
|
||||||
return nil, fmt.Errorf("zone %s not found on SakuraCloud DNS: %w", zoneName, err)
|
return nil, fmt.Errorf("zone %s not found on SakuraCloud DNS: %w", zoneName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("API call failed: %w", err)
|
return nil, fmt.Errorf("API call failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ type DNSProvider struct {
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
values, err := env.Get(EnvPddToken)
|
values, err := env.Get(EnvPddToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("yandex: %v", err)
|
return nil, fmt.Errorf("yandex: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
config := NewDefaultConfig()
|
config := NewDefaultConfig()
|
||||||
|
@ -79,7 +79,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
|
|
||||||
client, err := internal.NewClient(config.PddToken)
|
client, err := internal.NewClient(config.PddToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("yandex: %v", err)
|
return nil, fmt.Errorf("yandex: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.HTTPClient != nil {
|
if config.HTTPClient != nil {
|
||||||
|
@ -95,7 +95,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
|
|
||||||
rootDomain, subDomain, err := splitDomain(fqdn)
|
rootDomain, subDomain, err := splitDomain(fqdn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("yandex: %v", err)
|
return fmt.Errorf("yandex: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data := internal.Record{
|
data := internal.Record{
|
||||||
|
@ -108,7 +108,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
|
|
||||||
_, err = d.client.AddRecord(data)
|
_, err = d.client.AddRecord(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("yandex: %v", err)
|
return fmt.Errorf("yandex: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -120,12 +120,12 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
|
|
||||||
rootDomain, subDomain, err := splitDomain(fqdn)
|
rootDomain, subDomain, err := splitDomain(fqdn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("yandex: %v", err)
|
return fmt.Errorf("yandex: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
records, err := d.client.GetRecords(rootDomain)
|
records, err := d.client.GetRecords(rootDomain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("yandex: %v", err)
|
return fmt.Errorf("yandex: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var record *internal.Record
|
var record *internal.Record
|
||||||
|
@ -148,7 +148,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
|
|
||||||
_, err = d.client.RemoveRecord(data)
|
_, err = d.client.RemoveRecord(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("yandex: %v", err)
|
return fmt.Errorf("yandex: %w", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,8 @@ func (r *Registrar) Register(options RegisterOptions) (*Resource, error) {
|
||||||
account, err := r.core.Accounts.New(accMsg)
|
account, err := r.core.Accounts.New(accMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// FIXME seems impossible
|
// FIXME seems impossible
|
||||||
errorDetails, ok := err.(acme.ProblemDetails)
|
var errorDetails acme.ProblemDetails
|
||||||
if !ok || errorDetails.HTTPStatus != http.StatusConflict {
|
if !errors.As(err, &errorDetails) || errorDetails.HTTPStatus != http.StatusConflict {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,9 +81,9 @@ func (r *Registrar) RegisterWithExternalAccountBinding(options RegisterEABOption
|
||||||
|
|
||||||
account, err := r.core.Accounts.NewEAB(accMsg, options.Kid, options.HmacEncoded)
|
account, err := r.core.Accounts.NewEAB(accMsg, options.Kid, options.HmacEncoded)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorDetails, ok := err.(acme.ProblemDetails)
|
|
||||||
// FIXME seems impossible
|
// FIXME seems impossible
|
||||||
if !ok || errorDetails.HTTPStatus != http.StatusConflict {
|
var errorDetails acme.ProblemDetails
|
||||||
|
if !errors.As(err, &errorDetails) || errorDetails.HTTPStatus != http.StatusConflict {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ func (r *Registrar) RegisterWithExternalAccountBinding(options RegisterEABOption
|
||||||
// This is similar to the Register function,
|
// This is similar to the Register function,
|
||||||
// but acting on an existing registration link and resource.
|
// but acting on an existing registration link and resource.
|
||||||
func (r *Registrar) QueryRegistration() (*Resource, error) {
|
func (r *Registrar) QueryRegistration() (*Resource, error) {
|
||||||
if r == nil || r.user == nil {
|
if r == nil || r.user == nil || r.user.GetRegistration() == nil {
|
||||||
return nil, errors.New("acme: cannot query the registration of a nil client or user")
|
return nil, errors.New("acme: cannot query the registration of a nil client or user")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue