Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main' into 7738-aut…
Browse files Browse the repository at this point in the history
…o-pause-zombie-clients
  • Loading branch information
kruti-s committed Oct 29, 2024
2 parents 6c4e2fe + 3377102 commit 97aebfc
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 16 deletions.
5 changes: 5 additions & 0 deletions ca/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,11 @@ func (ca *certificateAuthorityImpl) issuePrecertificateInner(ctx context.Context
return nil, nil, berrors.InternalServerError("failed to prepare precertificate signing: %s", err)
}

// Note: we write the linting certificate bytes to this table, rather than the precertificate
// (which we audit log but do not put in the database). This is to ensure that even if there is
// an error immediately after signing the precertificate, we have a record in the DB of what we
// intended to sign, and can do revocations based on that. See #6807.
// The name of the SA method ("AddPrecertificate") is a historical artifact.
_, err = ca.sa.AddPrecertificate(context.Background(), &sapb.AddCertificateRequest{
Der: lintCertBytes,
RegID: issueReq.RegistrationID,
Expand Down
4 changes: 2 additions & 2 deletions core/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,13 @@ func (ch Challenge) StringID() string {
type Authorization struct {
// An identifier for this authorization, unique across
// authorizations and certificates within this instance.
ID string `json:"id,omitempty" db:"id"`
ID string `json:"-" db:"id"`

// The identifier for which authorization is being given
Identifier identifier.ACMEIdentifier `json:"identifier,omitempty" db:"identifier"`

// The registration ID associated with the authorization
RegistrationID int64 `json:"regId,omitempty" db:"registrationID"`
RegistrationID int64 `json:"-" db:"registrationID"`

// The status of the validation of this authorization
Status AcmeStatus `json:"status,omitempty" db:"status"`
Expand Down
13 changes: 12 additions & 1 deletion issuance/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,18 @@ func NewProfile(profileConfig *ProfileConfig) (*Profile, error) {
return nil, fmt.Errorf("validity period %q is too large", profileConfig.MaxValidityPeriod.Duration)
}

lints, err := linter.NewRegistry(profileConfig.IgnoredLints)
// TODO(#7756): These lint names don't yet exist in our current zlint v3.6.0 but exist in v3.6.2.
// In order to upgrade without throwing errors, we need to add these to our ignored lints.
// However, v3.6.0 will error if it sees ignored lints it doesn't recognize. Solution: filter
// out these specific lints. As part of the PR that updates to v3.6.2, we will remove this code.
var ignoredLints []string
for _, lintName := range profileConfig.IgnoredLints {
if lintName != "e_cab_dv_subject_invalid_values" && lintName != "w_ext_subject_key_identifier_not_recommended_subscriber" {
ignoredLints = append(ignoredLints, lintName)
}
}

lints, err := linter.NewRegistry(ignoredLints)
cmd.FailOnError(err, "Failed to create zlint registry")
if profileConfig.LintConfig != "" {
lintconfig, err := lint.NewConfigFromFile(profileConfig.LintConfig)
Expand Down
2 changes: 1 addition & 1 deletion sa/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func initTables(dbMap *borp.DbMap) {
dbMap.AddTableWithName(authzModel{}, "authz2").SetKeys(true, "ID")
dbMap.AddTableWithName(orderToAuthzModel{}, "orderToAuthz2").SetKeys(false, "OrderID", "AuthzID")
dbMap.AddTableWithName(recordedSerialModel{}, "serials").SetKeys(true, "ID")
dbMap.AddTableWithName(precertificateModel{}, "precertificates").SetKeys(true, "ID")
dbMap.AddTableWithName(lintingCertModel{}, "precertificates").SetKeys(true, "ID")
dbMap.AddTableWithName(keyHashModel{}, "keyHashToSerial").SetKeys(true, "ID")
dbMap.AddTableWithName(incidentModel{}, "incidents").SetKeys(true, "ID")
dbMap.AddTable(incidentSerialModel{})
Expand Down
3 changes: 3 additions & 0 deletions sa/db/boulder_sa/20230419000000_CombinedSchema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ CREATE TABLE `orders` (
PARTITION BY RANGE(id)
(PARTITION p_start VALUES LESS THAN (MAXVALUE));

-- Note: This table's name is a historical artifact and it is now
-- used to store linting certificates, not precertificates.
-- See #6807.
CREATE TABLE `precertificates` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`registrationID` bigint(20) NOT NULL,
Expand Down
4 changes: 2 additions & 2 deletions sa/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const precertFields = "registrationID, serial, der, issued, expires"
// SelectPrecertificate selects all fields of one precertificate object
// identified by serial.
func SelectPrecertificate(ctx context.Context, s db.OneSelector, serial string) (core.Certificate, error) {
var model precertificateModel
var model lintingCertModel
err := s.SelectOne(
ctx,
&model,
Expand Down Expand Up @@ -384,7 +384,7 @@ type recordedSerialModel struct {
Expires time.Time
}

type precertificateModel struct {
type lintingCertModel struct {
ID int64
Serial string
RegistrationID int64
Expand Down
8 changes: 6 additions & 2 deletions sa/sa.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ func (ssa *SQLStorageAuthority) SetCertificateStatusReady(ctx context.Context, r
return &emptypb.Empty{}, nil
}

// AddPrecertificate writes a record of a precertificate generation to the DB.
// AddPrecertificate writes a record of a linting certificate to the database.
//
// Note: The name "AddPrecertificate" is a historical artifact, and this is now
// always called with a linting certificate. See #6807.
//
// Note: this is not idempotent: it does not protect against inserting the same
// certificate multiple times. Calling code needs to first insert the cert's
// serial into the Serials table to ensure uniqueness.
Expand All @@ -221,7 +225,7 @@ func (ssa *SQLStorageAuthority) AddPrecertificate(ctx context.Context, req *sapb
}
serialHex := core.SerialToString(parsed.SerialNumber)

preCertModel := &precertificateModel{
preCertModel := &lintingCertModel{
Serial: serialHex,
RegistrationID: req.RegID,
DER: req.Der,
Expand Down
6 changes: 1 addition & 5 deletions wfe2/wfe.go
Original file line number Diff line number Diff line change
Expand Up @@ -1207,8 +1207,7 @@ func (wfe *WebFrontEndImpl) prepChallengeForDisplay(request *http.Request, authz
}

// prepAuthorizationForDisplay takes a core.Authorization and prepares it for
// display to the client by clearing its ID and RegistrationID fields, and
// preparing all its challenges.
// display to the client by preparing all its challenges.
func (wfe *WebFrontEndImpl) prepAuthorizationForDisplay(request *http.Request, authz *core.Authorization) {
for i := range authz.Challenges {
wfe.prepChallengeForDisplay(request, *authz, &authz.Challenges[i])
Expand All @@ -1219,9 +1218,6 @@ func (wfe *WebFrontEndImpl) prepAuthorizationForDisplay(request *http.Request, a
authz.Challenges[i], authz.Challenges[j] = authz.Challenges[j], authz.Challenges[i]
})

authz.ID = ""
authz.RegistrationID = 0

// The ACME spec forbids allowing "*" in authorization identifiers. Boulder
// allows this internally as a means of tracking when an authorization
// corresponds to a wildcard request (e.g. to handle CAA properly). We strip
Expand Down
8 changes: 5 additions & 3 deletions wfe2/wfe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3401,9 +3401,11 @@ func TestPrepAuthzForDisplay(t *testing.T) {
// This modifies the authz in-place.
wfe.prepAuthorizationForDisplay(&http.Request{Host: "localhost"}, authz)

// The ID and RegID should be empty, since they're not part of the ACME API object.
test.AssertEquals(t, authz.ID, "")
test.AssertEquals(t, authz.RegistrationID, int64(0))
// Ensure ID and RegID are omitted.
authzJSON, err := json.Marshal(authz)
test.AssertNotError(t, err, "Failed to marshal authz")
test.AssertNotContains(t, string(authzJSON), "\"id\":\"12345\"")
test.AssertNotContains(t, string(authzJSON), "\"registrationID\":\"1\"")
}

func TestPrepRevokedAuthzForDisplay(t *testing.T) {
Expand Down

0 comments on commit 97aebfc

Please sign in to comment.