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

Implement 'replaces' field in newOrder and draft-ietf-acme-ari-03 CertID changes #2114

Conversation

beautifulentropy
Copy link
Contributor

@beautifulentropy beautifulentropy commented Feb 16, 2024

  • Implement the updated CertID formation, as per draft-ietf-acme-ari-03.
  • Implement the "replaces" field in newOrder for indicating an order is a replacement at renewal time, as per draft-ietf-acme-ari-03.
  • Discontinue and remove the POST method implementation for indicating replacement success, deprecated in draft-ietf-acme-ari-03.

https://datatracker.ietf.org/doc/draft-ietf-acme-ari/


PLEASE NOTE: this MUST NOT be merged until letsencrypt/boulder#7298 is deployed to Production. I'll keep this issue up-to-date.

@beautifulentropy beautifulentropy force-pushed the draft-ietf-acme-ari-02-new-order-replaces branch from 4618bf5 to a22d17e Compare February 16, 2024 16:39
@beautifulentropy beautifulentropy changed the title Add support for newOrder 'replaces' field as per draft-ietf-acme-ari-02 Feb 16, 2024
@beautifulentropy beautifulentropy changed the title Implement 'replaces' Field in newOrder as per draft-ietf-acme-ari-02 Feb 16, 2024
@beautifulentropy
Copy link
Contributor Author

This is expected and has occurred in the two previous ARI PRs that touch renewForDomains.

Error: cmd/cmd_renew.go:128:1: cyclomatic complexity 14 of func `renewForDomains` is high (> 12) (gocyclo)
func renewForDomains(ctx *cli.Context, client *lego.Client, certsStorage *CertificatesStorage, bundle bool, meta map[string]string) error {
@ldez
Copy link
Member

ldez commented Feb 24, 2024

The current failure of the CI is related to a Pebble bug, I fixed the problem inside #2119.
So I will just rebase your PR to pass the CI.

@ldez ldez force-pushed the draft-ietf-acme-ari-02-new-order-replaces branch from e371021 to 79e475e Compare February 24, 2024 20:20
@beautifulentropy beautifulentropy changed the title Implement 'replaces' field in newOrder as per draft-ietf-acme-ari-02 Mar 1, 2024
@beautifulentropy beautifulentropy marked this pull request as ready for review March 7, 2024 20:23
@beautifulentropy
Copy link
Contributor Author

@ldez the changes necessary to support this contribution have been deployed at Let's Encrypt. Let me know if you need anything else.

@ldez ldez added this to the v4.16 milestone Mar 8, 2024
Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ldez
Copy link
Member

ldez commented Mar 8, 2024

I missed the conflict 😢

@ldez ldez force-pushed the draft-ietf-acme-ari-02-new-order-replaces branch from 373bb82 to 0c6f225 Compare March 8, 2024 15:04
@ldez ldez enabled auto-merge (squash) March 8, 2024 15:05
@ldez ldez merged commit 6dd8d03 into go-acme:master Mar 8, 2024
7 checks passed
Comment on lines +94 to +107
der, err := asn1.Marshal(leaf.SerialNumber)
if err != nil {
return err
return "", err
}

return nil
}

// makeARICertID constructs a certificate identifier as described in draft-ietf-acme-ari-02, section 4.1.
func makeARICertID(leaf *x509.Certificate) (string, error) {
if leaf == nil {
return "", errors.New("leaf certificate is nil")
// Check if the DER encoded bytes are sufficient (at least 3 bytes: tag,
// length, and value).
if len(der) < 3 {
return "", errors.New("invalid DER encoding of serial number")
}

return fmt.Sprintf("%s.%s",
strings.TrimRight(base64.URLEncoding.EncodeToString(leaf.AuthorityKeyId), "="),
strings.TrimRight(base64.URLEncoding.EncodeToString(leaf.SerialNumber.Bytes()), "="),
), nil
// Extract only the integer bytes from the DER encoded Serial Number
// Skipping the first 2 bytes (tag and length).
serial := base64.RawURLEncoding.EncodeToString(der[2:])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beautifulentropy Just curious, why the ASN.1 marshaling and byte stripping? In my testing, leaf.SerialNumber.Bytes() yields the same output as the more complex ASN.1 algorithm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ari ACME Renewal Information Extension area/lib enhancement
3 participants