Commit Graph

21 Commits

Author SHA1 Message Date
Matt Holt
193db7523a
Sync ACME account registration (#293)
https://caddy.community/t/lets-encrypt-hits-rate-limit-too-many-registrations-for-this-ip/24343
2024-06-06 05:17:18 -06:00
Matthew Holt
a1e1bd6ab5
More logging about account loading/creation 2024-06-03 19:47:29 -06:00
Andreas Kohn
27ab129028
Use configured email to pin to specific account key in storage (#283)
* Use the `email` configuration in the ACME issuer to "pin" an account to a key

When the issuer is configured with both an email and key material, these should match -- but that also means we
can use the email information to predict the key-key, skipping the potentially expensive storage.List operation.

* `continue` when we cannot load the private key for an account

Not being able to load this might be caused by a storage problem, or it could have been something
we did earlier. In either case we do not know whether this is the account we're looking for, and breaking
out now will trigger expensive calls to the ACME server to lookup the account and then save that account
again even though it was perfectly fine to begin with.

* Add unit tests for the changed behaviors
2024-04-18 13:42:33 -06:00
Matthew Holt
74862ff45a
Upgrade acmez to v2 beta
Adds support for customizing NotBefore/NotAfter times of certs
2024-04-08 14:05:43 -06:00
Matt Holt
c82ff34ad2
Retry with new account if account disappeared remotely (#269)
* Retry with new account if account disappeared remotely

* Emit log when account is missing from ACME server
2024-03-14 15:35:35 -06:00
Matthew Holt
5981e55018
Fix race conditions (close #195)
Also update setting acmez.Client.Logger in accordance
with latest acmez commit, which removes redundant
logger.
2022-08-01 23:04:11 -06:00
Matthew Holt
9b9f842b03
Rename getEmail -> setEmail
It doesn't really return the email address; it mutates the ACMEIssuer.
2022-07-05 16:56:22 -06:00
Matthew Holt
55be6d8695
Rename ACMEManager -> ACMEIssuer, CertificateManager -> Manager
This is necessary to eliminate confusing naming conventions, since now
we have Manager types, having an issuer called ACMEManager was
confusing.

CertificateManager is a redundant name as this package is called
CertMagic, so that a Manager manages certificates should be obvious.
It's also more succinct. Plus, it's consistent with Issuer which is not
named CertificateIssuer.
2022-03-24 11:34:31 -06:00
Dave Henderson
9a56fcd4f9
Propagate context in the Storage interface methods (#155)
* Add context propagation to the Storage interface

Signed-off-by: Dave Henderson <dhenderson@gmail.com>

* Bump to Go 1.17

* Minor cleanup

* filestorage: Honor context cancellation in List()

Co-authored-by: Matthew Holt <mholt@users.noreply.github.com>
2022-03-07 12:26:52 -07:00
Matt Holt
2d114193c3
storage: Require fs.ErrNotExist (fix #168) (#170)
Also stop using the deprecated io/ioutil package.
Update dependencies.
Update Go version in go.mod.
2022-03-07 11:11:20 -07:00
Matt Holt
797d29bcf3
GetCertificate from external certificate sources (Managers) (#163)
This work made possible by Tailscale: https://tailscale.com - thank you to the Tailscale team!

* Implement custom GetCertificate callback

Useful if another entity is managing certificates and can
provide its own dynamically during handshakes.

* Refactor CustomGetCertificate into OnDemandConfig

* Set certs to managed=true

This is only sorta true, but it allows handshake-time maintenance of the
certificates that are cached from CustomGetCertificate.

Our background maintenance routine skips certs that are OnDemand so it
should be fine.

* Change CustomGetCertificate into interface value

Instead of a function

* Case-insensitive subject name comparison

Hostnames are case-insensitive

Also add context to GetCertificate

* Export a couple of outrageously useful functions

* Allow multiple custom certificate getters

Also minor refactoring and enhancements

* Fix tests

* Rename Getter -> Manager; refactor

And don't cache externally managed certs

* Minor updates to comments
2022-02-17 14:37:50 -07:00
Matthew Holt
1c89882bc5 Move unused test variable 2021-10-27 14:15:20 -06:00
Matthew Holt
a1d00125a6
Sync discovered contact email (fix #127) 2021-04-12 11:57:20 -06:00
Matthew Holt
6131a445f6
Remove old asset migration code
https://github.com/caddyserver/caddy/issues/3894
2021-02-22 15:17:10 -07:00
Matthew Holt
07dc55f031
Look up account in storage first
This avoids contacting the server if we already have the account info in storage.
2021-01-20 16:01:53 -07:00
Matthew Holt
5259faf208
Support account lookup by private key
This enables adding existing accounts to storage so they
can be used in future ACME transactions, as long as the
private key is possessed.
2021-01-20 14:52:08 -07:00
Matthew Holt
18811087a7
Properly splice invalid accounts
Related to: https://github.com/caddyserver/caddy/issues/3939

Avoids a panic in the event ALL items listed are "terminal" - the linked specific case is surely a bug in the upstream storage implementation, but we shouldn't panic anyway.
2020-12-28 09:05:11 -07:00
Matt Holt
0f8a9f6887
Implement multiple issuer support (#109)
* Implement multiple issuer support

This change refactors Config.Issuer to be Config.Issuers, an array of
issuers. Each Issuer will be tried in turn until one succeeds. During
retries, each attempt will try each configured Issuer. When loading
certs from storage, CertMagic will look in each Issuer's storage
location for a qualifying asset. If multiple Issuers have one in storage
then the most-recently-issued cert will be selected.

This is a breaking change in that Config now accepts a slice of Issuers
rather than a single Issuer. The Revoker field is removed, as supporting
it is optional anyway. If the Issuer is also a Revoker, it can be used
implicitly to revoke certificates.

Also added a const for ZeroSSL's ACME endpoint.

* Load matching wildcard on-demand from storage

With this change, a config using on-demand TLS can load a certificate
for "sub.example.com" from storage using a matching  wildcard cert
(i.e. "*.example.com") if no better matching certificate is available.

* Fix distributed solving with tls-alpn challenges

The type assertion in handshake.go was problematic since there's no
guarantee that an ACME issuer would be a concrete ACMEManager type.

Refactored the code to accept IssuerKey values generally, rather than
specific ACMEManager values only.

This fixes solving tls-alpn challenges in distributed settings.

More cleanup can be done, another time.
2020-11-16 10:53:41 -07:00
M. Ángel Jimeno
0c8b028721
account: handle decodePrivateKey() error in getAccount (#89) 2020-08-26 12:54:29 -06:00
Matthew Holt
27ab38448f
Gracefully transition existing meta assets to new format
The new format is dictated primarily by the ACME spec as implemented by
the new acmez/acme package. It makes a lot more sense.
2020-07-30 12:13:45 -06:00
Matt Holt
b76b76abfc
Replace lego with ACMEz (close #71) (#78) 2020-07-27 16:50:41 -06:00