Skip to content

ra: Guarantee an audit completion line for every issuance attempt - #8846

Closed
beautifulentropy wants to merge 1 commit into
reland-slogfrom
slog-audit/07-ra-issuance-completion
Closed

ra: Guarantee an audit completion line for every issuance attempt#8846
beautifulentropy wants to merge 1 commit into
reland-slogfrom
slog-audit/07-ra-issuance-completion

Conversation

@beautifulentropy

@beautifulentropy beautifulentropy commented Jul 6, 2026

Copy link
Copy Markdown
Member

issueCertificateOuter logs "Authz used for issuance" audit lines up front, with a comment promising they always correlate (via the shared id attr) with a completion line. Two exits broke that promise: the renewal-check (FQDNSetTimestampsForWindow) error return, and the entire MTC branch.

Log "Certificate request - error" on the renewal-check failure path. Move MTC dispatch from issueCertificateOuter into issueCertificateInner, so a failed MTC issuance flows through the same failOrder and "Certificate request - error" handling as classic issuance. Upgrade the MTC success line ("issued MTC") to an audit log so MTC issuance has an audit-tagged completion record. Also fix the comment (which referenced "Certificate request complete", a message renamed during #8606 review).

This PR was generated as part of an audit of #8606 using Claude Fable 5.

issueCertificateOuter logs "Authz used for issuance" audit lines up
front, with a comment promising they always correlate (via the shared
id attr) with a completion line. Two exits broke that promise: the
renewal-check (FQDNSetTimestampsForWindow) error return, and the entire
MTC branch.

Log "Certificate request - error" on the renewal-check failure path.
Move MTC dispatch from issueCertificateOuter into
issueCertificateInner, so a failed MTC issuance flows through the same
failOrder and "Certificate request - error" handling as classic
issuance. Because the dispatch sits below the CAA recheck block, MTC
orders now also receive CAA rechecks under the CAARechecksFailOrder
flag, matching their behavior when the flag is off. Upgrade the MTC
success line ("issued MTC") to an audit log so MTC issuance has an
audit-tagged completion record. Also fix the comment (which referenced
"Certificate request complete", a message renamed during #8606
review).
@beautifulentropy
beautifulentropy requested a review from a team as a code owner July 6, 2026 19:03
@beautifulentropy
beautifulentropy requested a review from ezekiel July 6, 2026 19:03
@beautifulentropy beautifulentropy changed the title ra: guarantee an audit completion line for every issuance attempt ra: Guarantee an audit completion line for every issuance attempt Jul 6, 2026
@ezekiel
ezekiel requested review from a team and aarongable and removed request for a team July 6, 2026 20:08
@aarongable
aarongable changed the base branch from main to reland-slog July 6, 2026 21:19
Comment thread ra/ra.go
Comment on lines +1112 to +1116
} else if cert == nil {
// MTC issuance produced no classic certificate, so there is no serial
// or validity period to record on the order. Its completion record is
// the "issued MTC" audit line logged by issueMTC.
return order, nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We shouldn't special case this, for two reasons:

  1. We want all of our issuance to have log lines of the same shape. The whole point of moving issueMTC inside issueInner was so that we could take advantage of the log line on line 1127. This conditional makes that pointless.
  2. We do have the serial number: it's computable from the entryIndex returned by issueMTC.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We do want our log lines to have the same shape, but there's a trickiness: issuerCertificateInner returns a *x509.Certificate, and the log line below pulls fields from it to log.

By the time issueMTC returns, there is not yet a certificate. We have "issued" a TBSCertificateLogEntry, but are awaiting a mirror signature to make a standalone certificate.

I think we can square the circle like so:

  • Define a TBSCertificateLogEntry type with serialization and deserialization (we need to do this anyhow for the MTCA work).
  • Return that as part of the MTCA.Issue() call.
  • In RA, parse that TBSCertificateLogEntry.
  • In RA, define a wrapper that can extract useful fields (serial, CommonName, NotBefore, NotAfter) from either an *x509.Certificate or a TBSCertificateLogEntry.
  • Use that wrapper to emit the log line.

However, since this requires some refactorings and more implementation I think we shouldn't let it block the slog work. Let's leave the issueMTC call where it is and file an issue for followup as part of MTC implementation.

Comment thread ra/ra.go
return nil, err
}

_, err = ra.SA.FinalizeOrder(ctx, &sapb.FinalizeOrderRequest{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This review has made me realize that I think issueMTC is missing a call to SA.FinalizeOrder (cc: @jsha)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It doesn't have that call because once issueMTC returns, the order will still be in "processing" state until we have a mirror cosignature on the relevant checkpoint.

Comment thread ra/ra.go
Comment on lines +1078 to +1084
err = fmt.Errorf("checking if certificate is a renewal: %w", err)
ra.log.AuditInfo(ctx, "Certificate request - error",
slog.String("result", "error"),
slog.Time("responseTime", ra.clk.Now()),
blog.Error(err),
)
return nil, err

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The goal of this PR is to fulfill the comment on lines 1045-1047:

these authz logs will always correspond to (and carry the same id field as) a completion line logged below

But for this part of the change, think it would be a lot simpler to move the whole "log the authzs" stanza to just before the issueCertificateInner call. That would mean that failures to check whether a certificate is a renewal wouldn't log "Certificate request - error", and also would would not log the authz lines. I think that's okay.

Comment thread ra/ra.go
Comment on lines +1112 to +1116
} else if cert == nil {
// MTC issuance produced no classic certificate, so there is no serial
// or validity period to record on the order. Its completion record is
// the "issued MTC" audit line logged by issueMTC.
return order, nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We do want our log lines to have the same shape, but there's a trickiness: issuerCertificateInner returns a *x509.Certificate, and the log line below pulls fields from it to log.

By the time issueMTC returns, there is not yet a certificate. We have "issued" a TBSCertificateLogEntry, but are awaiting a mirror signature to make a standalone certificate.

I think we can square the circle like so:

  • Define a TBSCertificateLogEntry type with serialization and deserialization (we need to do this anyhow for the MTCA work).
  • Return that as part of the MTCA.Issue() call.
  • In RA, parse that TBSCertificateLogEntry.
  • In RA, define a wrapper that can extract useful fields (serial, CommonName, NotBefore, NotAfter) from either an *x509.Certificate or a TBSCertificateLogEntry.
  • Use that wrapper to emit the log line.

However, since this requires some refactorings and more implementation I think we shouldn't let it block the slog work. Let's leave the issueMTC call where it is and file an issue for followup as part of MTC implementation.

@beautifulentropy

Copy link
Copy Markdown
Member Author

I'm going to close this out and let it be fixed as part of the MTC project.

@beautifulentropy
beautifulentropy deleted the slog-audit/07-ra-issuance-completion branch August 14, 2026 19:05
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.

4 participants