-
Notifications
You must be signed in to change notification settings - Fork 155
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
Multi-validation & true async issuance #17
Changes from 2 commits
5491a24
7d615b5
6ea9faa
ddc2ed9
39e794e
ead0639
802400a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import ( | |
"math/big" | ||
"time" | ||
|
||
"github.com/letsencrypt/pebble/acme" | ||
"github.com/letsencrypt/pebble/core" | ||
"github.com/letsencrypt/pebble/db" | ||
) | ||
|
@@ -152,7 +153,7 @@ func (ca *CAImpl) newIntermediateIssuer() error { | |
return nil | ||
} | ||
|
||
func (ca *CAImpl) NewCertificate(domains []string, key crypto.PublicKey) (*core.Certificate, error) { | ||
func (ca *CAImpl) newCertificate(domains []string, key crypto.PublicKey) (*core.Certificate, error) { | ||
var cn string | ||
if len(domains) > 0 { | ||
cn = domains[0] | ||
|
@@ -218,3 +219,40 @@ func New(log *log.Logger, db *db.MemoryStore) *CAImpl { | |
} | ||
return ca | ||
} | ||
|
||
func (ca *CAImpl) CompleteOrder(order *core.Order) { | ||
// Check the authorizations - this is done by the VA before calling | ||
// CompleteOrder but we do it again for robustness sake. | ||
for _, authz := range order.AuthorizationObjects { | ||
if authz.Status != acme.StatusValid { | ||
return | ||
} | ||
} | ||
|
||
if order.Status != acme.StatusPending { | ||
ca.log.Printf("Error: Asked to complete orrder %s is not status pending, was status %s", | ||
order.ID, order.Status) | ||
return | ||
} | ||
|
||
ca.log.Printf("Order %s is fully authorized. Ready to issue", order.ID) | ||
// Update the order to reflect that we're now processing it | ||
order.Status = acme.StatusProcessing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to hold a lock on the order. |
||
|
||
csr := order.ParsedCSR | ||
domains := make([]string, len(csr.DNSNames)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to make a copy? |
||
copy(domains, csr.DNSNames) | ||
|
||
// issue a certificate for the csr | ||
cert, err := ca.newCertificate(domains, csr.PublicKey) | ||
if err != nil { | ||
ca.log.Printf("Error: unable to issue order: %s", err.Error()) | ||
return | ||
} | ||
ca.log.Printf("Issued certificate serial %s\n", cert.ID) | ||
|
||
// Update the order to valid status with a certificate URL | ||
order.Status = acme.StatusValid | ||
order.Certificate = order.CertPathPrefix + cert.ID | ||
ca.log.Printf("Order %s has Certificate %s", order.ID, order.Certificate) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ type Order struct { | |
ParsedCSR *x509.CertificateRequest | ||
ExpiresDate time.Time | ||
AuthorizationObjects []*Authorization | ||
CertPathPrefix string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than embedding a public-facing path (WFE's responsibility) in the internal Order object, let's embed a certificate ID, and make WFE responsible for rendering that into a certificate path. |
||
} | ||
|
||
type Registration struct { | ||
|
@@ -98,3 +99,9 @@ func (c Certificate) Chain() []byte { | |
// Return the chain, leaf cert first | ||
return bytes.Join(chain, nil) | ||
} | ||
|
||
type ValidationRecord struct { | ||
URL string | ||
Error *acme.ProblemDetails | ||
ValidatedAt time.Time | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*order %s, which is not