Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/acme: Add support for custom validity certs #242

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion acme/autocert/autocert.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ type Manager struct {
// If zero, they're renewed 30 days before expiration.
RenewBefore time.Duration

// RequestedCertificateValidity optionally specifies the validity of the requested
// certificates from the CA. This may not be honored by all CAs. Ensure that this
// and RenewBefore make sense in both cases (honored and not honored).
//
// The CA default value is used if this is not set.
RequestedCertificateValidity time.Duration

// Client is used to perform low-level operations, such as account registration
// and requesting new certificates.
//
Expand Down Expand Up @@ -697,7 +704,14 @@ func (m *Manager) verifyRFC(ctx context.Context, client *acme.Client, domain str
nextTyp := 0 // challengeTypes index
AuthorizeOrderLoop:
for {
o, err := client.AuthorizeOrder(ctx, acme.DomainIDs(domain))
// Send the notAfter option to the CA
var orderOpts []acme.OrderOption
if m.RequestedCertificateValidity != 0 {
orderOpts = append(orderOpts, acme.WithOrderNotAfter(
time.Now().UTC().Add(m.RequestedCertificateValidity)))
}

o, err := client.AuthorizeOrder(ctx, acme.DomainIDs(domain), orderOpts...)
if err != nil {
return nil, err
}
Expand Down