Merge pull request #1227 from munnerz/use-cached-account-uri

Use cached ACME account URL when constructing ACME client
This commit is contained in:
jetstack-bot 2019-01-17 15:50:01 +00:00 committed by GitHub
commit 63562421b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -111,13 +111,20 @@ func ClientWithKey(iss cmapi.GenericIssuer, pk *rsa.PrivateKey) (acme.Interface,
if acmeSpec == nil {
return nil, fmt.Errorf("issuer %q is not an ACME issuer. Ensure the 'acme' stanza is correctly specified on your Issuer resource", iss.GetObjectMeta().Name)
}
return acmemw.NewLogger(&acmecl.Client{
acmeStatus := iss.GetStatus().ACME
accountURI := ""
if acmeStatus != nil && acmeStatus.URI != "" {
accountURI = acmeStatus.URI
}
acmeCl := &acmecl.Client{
HTTPClient: buildHTTPClient(acmeSpec.SkipTLSVerify),
Key: pk,
DirectoryURL: acmeSpec.Server,
UserAgent: util.CertManagerUserAgent,
}), nil
}
acmeCl.SetAccountURL(accountURI)
return acmemw.NewLogger(acmeCl), nil
}
// ClientForIssuer will return a properly configure ACME client for the given

View File

@ -90,6 +90,15 @@ type Client struct {
accountURL string
}
// SetAccountURL will set the account URL cached by the client.
// This should be used with caution, in order to reduce the number of calls
// made to the 'new-acct' endpoint in 'cacheAccountURL'
func (c *Client) SetAccountURL(url string) {
c.urlMu.Lock()
defer c.urlMu.Unlock()
c.accountURL = url
}
// Discover performs ACME server discovery using c.DirectoryURL.
//
// It caches successful result. So, subsequent calls will not result in