Commit Graph

12 Commits

Author SHA1 Message Date
Matthew Holt
88e840d8b9
Fix tests 2024-06-03 21:55:10 -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
5deb7c2fb0 Make logger values required
Eliminates a bajillion nil checks and footguns
(except in tests, which bypass exported APIs, but that is expected)

Most recent #207

Logging can still be disabled via zap.NewNop(), if necessary.
(But disabling logging in CertMagic is a really bad idea.)
2022-09-26 10:19:30 -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
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
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
Matthew Holt
e6076585c0
Convert (most of the library) to structured logs (closes #19)
Logging is now configurable through setting the Logging field on the
various relevant struct types. This is a more useful, consistent, and
higher-performing experience with logs than the std lib logger we used
before.

This isn't a 100% complete transition because there are some parts of
the code base that don't have obvious or easy access to a logger.
They are mostly fringe/edge cases though, and most are error logs, so
you shouldn't see them under normal circumstances. They still emit to
the std lib logger, so it's not like any errors get hidden: they are
just unstructured until we find a way to give them access to a logger.
2020-07-29 19:38:12 -06:00
Matt Holt
b76b76abfc
Replace lego with ACMEz (close #71) (#78) 2020-07-27 16:50:41 -06:00