-
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 5 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,44 @@ 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 { | ||
// Lock the authorization for reading | ||
authz.RLock() | ||
if authz.Status != acme.StatusValid { | ||
return | ||
} | ||
authz.RUnlock() | ||
} | ||
|
||
order.RLock() | ||
if order.Status != acme.StatusPending { | ||
ca.log.Printf("Error: Asked to complete order %s is not status pending, was status %s", | ||
order.ID, order.Status) | ||
return | ||
} | ||
order.RUnlock() | ||
|
||
// Update the order to reflect that we're now processing it | ||
order.Lock() | ||
defer order.Unlock() | ||
ca.log.Printf("Order %s is fully authorized. Ready to issue", order.ID) | ||
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 | ||
// issue a certificate for the csr | ||
cert, err := ca.newCertificate(csr.DNSNames, csr.PublicKey) | ||
if err != nil { | ||
ca.log.Printf("Error: unable to issue order: %s", err.Error()) | ||
return | ||
} | ||
ca.log.Printf("Issued certificate serial %s for order %s\n", cert.ID, order.ID) | ||
|
||
// Update the order to valid status and store a cert ID for the wfe to use to | ||
// render the certificate URL for the order | ||
order.Status = acme.StatusValid | ||
order.CertID = cert.ID | ||
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 you need to store a copy of 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 not use it directly" -> You mean a pointer to the certificate? 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. Yeah; I wrote this comment before the earlier one. Is the certificate stored in memory separately from the order? If so, then yes a pointer to the certificate would be good. Otherwise, DER should work. 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. Aha, should have read the latest diffs before replying. This looks great. 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. Since this field is only used to check whether a certificate is done, maybe it would be better to create a field that contains the cert DER, since we'll actually need that later. Otherwise, it's a bit confusing why there are two "ID" fields. |
||
} |
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.
You need to lock earlier, before you fetch order.AuthorixationObjects, Also I think a full lock would be fine; we're not worried about performance here, and there's no deadlock possibility, right?
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.
Good catch on locking too late here. Thanks.