Skip to content

Normalize the serial in NewCertID so ARI replaces lookups match - #556

Merged
aarongable merged 1 commit into
letsencrypt:mainfrom
shyney7:certid-normalize-serial
Sep 28, 2026
Merged

aarongable merged 1 commit into
letsencrypt:mainfrom
shyney7:certid-normalize-serial

Conversation

@shyney7

@shyney7 shyney7 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #550.

When a certificate's serial starts with a byte >= 0x80, ACME clients put an extra 00 in front of it in the ARI certID. That's correct, since RFC 9773 asks for the DER integer bytes. But Pebble stores issued certificates under the serial without that 00, so a new order with replaces for one of those certificates can't find the original and fails with a 500. This happens for about 1 in 256 certificates.

The fix builds the certID's lookup key from the parsed number instead of the raw bytes, so both forms give the same key. This is the same way the certificate is stored in ca.go, and the renewalInfo endpoint already looks things up this way.

Testing:

  • Added a unit test that checks the serial is the same with and without the leading 00.
  • I also tested the whole flow: I built Pebble with serials forced to start with a high byte, then issued a cert with acme.sh 3.1.6 and did a forced renewal. Without this change the renewal fails with "could not find an order for the given certificate". With it, the renewal succeeds and still sends replaces.

ARI certIDs carry the serial as DER INTEGER value bytes, which include a
leading 0x00 when the top bit is set. Issued certificates are indexed by
the hex of big.Int.Bytes(), which has no such byte, so a replaces
request for those certificates failed to find the original order.

Fixes letsencrypt#550
@mcpherrinm
mcpherrinm requested review from a team and jsha and removed request for a team September 23, 2026 16:00
@aarongable
aarongable merged commit 1fcb30c into letsencrypt:main Sep 28, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ARI replaces lookup misses when the certificate serial's top byte is >= 0x80

2 participants