Skip to content

Commit de8ded2

Browse files
Merge branch 'main' into dependabot/go_modules/aws-e559bdec09
2 parents ea4e6f8 + 20fdcbc commit de8ded2

File tree

11 files changed

+212
-194
lines changed

11 files changed

+212
-194
lines changed

ra/ra.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ func (ra *RegistrationAuthorityImpl) issueCertificateInner(
13581358
return nil, nil, wrapError(err, "parsing final certificate")
13591359
}
13601360

1361-
go ra.countCertificateIssued(ctx, int64(acctID), slices.Clone(parsedCertificate.DNSNames), isRenewal)
1361+
ra.countCertificateIssued(ctx, int64(acctID), slices.Clone(parsedCertificate.DNSNames), isRenewal)
13621362

13631363
// Asynchronously submit the final certificate to any configured logs
13641364
go ra.ctpolicy.SubmitFinalCert(cert.Der, parsedCertificate.NotAfter)
@@ -1998,12 +1998,10 @@ func (ra *RegistrationAuthorityImpl) PerformValidation(
19981998
if prob != nil {
19991999
challenge.Status = core.StatusInvalid
20002000
challenge.Error = prob
2001-
go func() {
2002-
err := ra.countFailedValidations(vaCtx, authz.RegistrationID, authz.Identifier)
2003-
if err != nil {
2004-
ra.log.Warningf("incrementing failed validations: %s", err)
2005-
}
2006-
}()
2001+
err := ra.countFailedValidations(vaCtx, authz.RegistrationID, authz.Identifier)
2002+
if err != nil {
2003+
ra.log.Warningf("incrementing failed validations: %s", err)
2004+
}
20072005
} else {
20082006
challenge.Status = core.StatusValid
20092007
if features.Get().AutomaticallyPauseZombieClients {

ratelimits/gcra_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
func TestDecide(t *testing.T) {
1313
clk := clock.NewFake()
14-
limit := limit{Burst: 10, Count: 1, Period: config.Duration{Duration: time.Second}}
14+
limit := &limit{Burst: 10, Count: 1, Period: config.Duration{Duration: time.Second}}
1515
limit.precompute()
1616

1717
// Begin by using 1 of our 10 requests.
@@ -138,7 +138,7 @@ func TestDecide(t *testing.T) {
138138

139139
func TestMaybeRefund(t *testing.T) {
140140
clk := clock.NewFake()
141-
limit := limit{Burst: 10, Count: 1, Period: config.Duration{Duration: time.Second}}
141+
limit := &limit{Burst: 10, Count: 1, Period: config.Duration{Duration: time.Second}}
142142
limit.precompute()
143143

144144
// Begin by using 1 of our 10 requests.

ratelimits/limit.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (l *limit) precompute() {
6363
l.burstOffset = l.emissionInterval * l.Burst
6464
}
6565

66-
func validateLimit(l limit) error {
66+
func validateLimit(l *limit) error {
6767
if l.Burst <= 0 {
6868
return fmt.Errorf("invalid burst '%d', must be > 0", l.Burst)
6969
}
@@ -76,7 +76,7 @@ func validateLimit(l limit) error {
7676
return nil
7777
}
7878

79-
type limits map[string]limit
79+
type limits map[string]*limit
8080

8181
// loadDefaults marshals the defaults YAML file at path into a map of limits.
8282
func loadDefaults(path string) (limits, error) {
@@ -156,7 +156,8 @@ func loadAndParseOverrideLimits(path string) (limits, error) {
156156

157157
for _, ov := range fromFile {
158158
for k, v := range ov {
159-
err = validateLimit(v.limit)
159+
limit := &v.limit
160+
err = validateLimit(limit)
160161
if err != nil {
161162
return nil, fmt.Errorf("validating override limit %q: %w", k, err)
162163
}
@@ -167,7 +168,6 @@ func loadAndParseOverrideLimits(path string) (limits, error) {
167168
v.limit.name = name
168169

169170
for _, entry := range v.Ids {
170-
limit := v.limit
171171
id := entry.Id
172172
err = validateIdForName(name, id)
173173
if err != nil {
@@ -248,11 +248,11 @@ func newLimitRegistry(defaults, overrides string) (*limitRegistry, error) {
248248
// required, bucketKey is optional. If bucketkey is empty, the default for the
249249
// limit specified by name is returned. If no default limit exists for the
250250
// specified name, errLimitDisabled is returned.
251-
func (l *limitRegistry) getLimit(name Name, bucketKey string) (limit, error) {
251+
func (l *limitRegistry) getLimit(name Name, bucketKey string) (*limit, error) {
252252
if !name.isValid() {
253253
// This should never happen. Callers should only be specifying the limit
254254
// Name enums defined in this package.
255-
return limit{}, fmt.Errorf("specified name enum %q, is invalid", name)
255+
return nil, fmt.Errorf("specified name enum %q, is invalid", name)
256256
}
257257
if bucketKey != "" {
258258
// Check for override.
@@ -265,5 +265,5 @@ func (l *limitRegistry) getLimit(name Name, bucketKey string) (limit, error) {
265265
if ok {
266266
return dl, nil
267267
}
268-
return limit{}, errLimitDisabled
268+
return nil, errLimitDisabled
269269
}

ratelimits/limit_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ func TestParseOverrideNameId(t *testing.T) {
4242
}
4343

4444
func TestValidateLimit(t *testing.T) {
45-
err := validateLimit(limit{Burst: 1, Count: 1, Period: config.Duration{Duration: time.Second}})
45+
err := validateLimit(&limit{Burst: 1, Count: 1, Period: config.Duration{Duration: time.Second}})
4646
test.AssertNotError(t, err, "valid limit")
4747

4848
// All of the following are invalid.
49-
for _, l := range []limit{
49+
for _, l := range []*limit{
5050
{Burst: 0, Count: 1, Period: config.Duration{Duration: time.Second}},
5151
{Burst: 1, Count: 0, Period: config.Duration{Duration: time.Second}},
5252
{Burst: 1, Count: 1, Period: config.Duration{Duration: 0}},

ratelimits/limiter_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ func TestRateLimitError(t *testing.T) {
497497
allowed: false,
498498
retryIn: 5 * time.Second,
499499
transaction: Transaction{
500-
limit: limit{
500+
limit: &limit{
501501
name: NewRegistrationsPerIPAddress,
502502
Burst: 10,
503503
Period: config.Duration{Duration: time.Hour},
@@ -513,7 +513,7 @@ func TestRateLimitError(t *testing.T) {
513513
allowed: false,
514514
retryIn: 10 * time.Second,
515515
transaction: Transaction{
516-
limit: limit{
516+
limit: &limit{
517517
name: NewRegistrationsPerIPv6Range,
518518
Burst: 5,
519519
Period: config.Duration{Duration: time.Hour},
@@ -529,7 +529,7 @@ func TestRateLimitError(t *testing.T) {
529529
allowed: false,
530530
retryIn: 10 * time.Second,
531531
transaction: Transaction{
532-
limit: limit{
532+
limit: &limit{
533533
name: NewOrdersPerAccount,
534534
Burst: 2,
535535
Period: config.Duration{Duration: time.Hour},
@@ -545,7 +545,7 @@ func TestRateLimitError(t *testing.T) {
545545
allowed: false,
546546
retryIn: 15 * time.Second,
547547
transaction: Transaction{
548-
limit: limit{
548+
limit: &limit{
549549
name: FailedAuthorizationsPerDomainPerAccount,
550550
Burst: 7,
551551
Period: config.Duration{Duration: time.Hour},
@@ -562,7 +562,7 @@ func TestRateLimitError(t *testing.T) {
562562
allowed: false,
563563
retryIn: 20 * time.Second,
564564
transaction: Transaction{
565-
limit: limit{
565+
limit: &limit{
566566
name: CertificatesPerDomain,
567567
Burst: 3,
568568
Period: config.Duration{Duration: time.Hour},
@@ -579,7 +579,7 @@ func TestRateLimitError(t *testing.T) {
579579
allowed: false,
580580
retryIn: 20 * time.Second,
581581
transaction: Transaction{
582-
limit: limit{
582+
limit: &limit{
583583
name: CertificatesPerDomainPerAccount,
584584
Burst: 3,
585585
Period: config.Duration{Duration: time.Hour},
@@ -596,7 +596,7 @@ func TestRateLimitError(t *testing.T) {
596596
allowed: false,
597597
retryIn: 30 * time.Second,
598598
transaction: Transaction{
599-
limit: limit{
599+
limit: &limit{
600600
name: 9999999,
601601
},
602602
},

ratelimits/transaction.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func newFQDNSetBucketKey(name Name, orderNames []string) (string, error) { //nol
107107
// it would fail validateTransaction (for instance because cost and burst are zero).
108108
type Transaction struct {
109109
bucketKey string
110-
limit limit
110+
limit *limit
111111
cost int64
112112
check bool
113113
spend bool
@@ -143,7 +143,7 @@ func validateTransaction(txn Transaction) (Transaction, error) {
143143
return txn, nil
144144
}
145145

146-
func newTransaction(limit limit, bucketKey string, cost int64) (Transaction, error) {
146+
func newTransaction(limit *limit, bucketKey string, cost int64) (Transaction, error) {
147147
return validateTransaction(Transaction{
148148
bucketKey: bucketKey,
149149
limit: limit,
@@ -153,7 +153,7 @@ func newTransaction(limit limit, bucketKey string, cost int64) (Transaction, err
153153
})
154154
}
155155

156-
func newCheckOnlyTransaction(limit limit, bucketKey string, cost int64) (Transaction, error) {
156+
func newCheckOnlyTransaction(limit *limit, bucketKey string, cost int64) (Transaction, error) {
157157
return validateTransaction(Transaction{
158158
bucketKey: bucketKey,
159159
limit: limit,
@@ -162,7 +162,7 @@ func newCheckOnlyTransaction(limit limit, bucketKey string, cost int64) (Transac
162162
})
163163
}
164164

165-
func newSpendOnlyTransaction(limit limit, bucketKey string, cost int64) (Transaction, error) {
165+
func newSpendOnlyTransaction(limit *limit, bucketKey string, cost int64) (Transaction, error) {
166166
return validateTransaction(Transaction{
167167
bucketKey: bucketKey,
168168
limit: limit,

va/caa.go

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"time"
1212

1313
"github.com/miekg/dns"
14-
"github.com/prometheus/client_golang/prometheus"
1514

1615
"github.com/letsencrypt/boulder/bdns"
1716
"github.com/letsencrypt/boulder/canceled"
@@ -42,19 +41,46 @@ func (va *ValidationAuthorityImpl) IsCAAValid(ctx context.Context, req *vapb.IsC
4241
Requester: req.AccountURIID,
4342
Hostname: req.Domain,
4443
}
45-
checkStartTime := va.clk.Now()
4644

47-
validationMethod := core.AcmeChallenge(req.ValidationMethod)
48-
if !validationMethod.IsValid() {
45+
challType := core.AcmeChallenge(req.ValidationMethod)
46+
if !challType.IsValid() {
4947
return nil, berrors.InternalServerError("unrecognized validation method %q", req.ValidationMethod)
5048
}
5149

5250
acmeID := identifier.NewDNS(req.Domain)
5351
params := &caaParams{
5452
accountURIID: req.AccountURIID,
55-
validationMethod: validationMethod,
53+
validationMethod: challType,
5654
}
5755

56+
var prob *probs.ProblemDetails
57+
var internalErr error
58+
var localLatency time.Duration
59+
start := va.clk.Now()
60+
61+
defer func() {
62+
probType := ""
63+
outcome := fail
64+
if prob != nil {
65+
// CAA check failed.
66+
probType = string(prob.Type)
67+
logEvent.Error = prob.Error()
68+
} else {
69+
// CAA check passed.
70+
outcome = pass
71+
}
72+
// Observe local check latency (primary|remote).
73+
va.observeLatency(opCAA, va.perspective, string(challType), probType, outcome, localLatency)
74+
if va.isPrimaryVA() {
75+
// Observe total check latency (primary+remote).
76+
va.observeLatency(opCAA, allPerspectives, string(challType), probType, outcome, va.clk.Since(start))
77+
}
78+
// Log the total check latency.
79+
logEvent.ValidationLatency = va.clk.Since(start).Round(time.Millisecond).Seconds()
80+
81+
va.log.AuditObject("CAA check result", logEvent)
82+
}()
83+
5884
var remoteCAAResults chan *remoteVAResult
5985
if features.Get().EnforceMultiCAA {
6086
if remoteVACount := len(va.remoteVAs); remoteVACount > 0 {
@@ -63,16 +89,10 @@ func (va *ValidationAuthorityImpl) IsCAAValid(ctx context.Context, req *vapb.IsC
6389
}
6490
}
6591

66-
checkResult := "success"
67-
err := va.checkCAA(ctx, acmeID, params)
68-
localCheckLatency := time.Since(checkStartTime)
69-
var prob *probs.ProblemDetails
70-
if err != nil {
71-
prob = detailedError(err)
72-
logEvent.Error = prob.Error()
73-
logEvent.InternalError = err.Error()
92+
internalErr = va.checkCAA(ctx, acmeID, params)
93+
if internalErr != nil {
94+
prob = detailedError(internalErr)
7495
prob.Detail = fmt.Sprintf("While processing CAA for %s: %s", req.Domain, prob.Detail)
75-
checkResult = "failure"
7696
} else if remoteCAAResults != nil {
7797
if !features.Get().EnforceMultiCAA && features.Get().MultiCAAFullResults {
7898
// If we're not going to enforce multi CAA but we are logging the
@@ -82,40 +102,24 @@ func (va *ValidationAuthorityImpl) IsCAAValid(ctx context.Context, req *vapb.IsC
82102
_ = va.processRemoteCAAResults(
83103
req.Domain,
84104
req.AccountURIID,
85-
string(validationMethod),
105+
string(challType),
86106
remoteCAAResults)
87107
}()
88108
} else if features.Get().EnforceMultiCAA {
89109
remoteProb := va.processRemoteCAAResults(
90110
req.Domain,
91111
req.AccountURIID,
92-
string(validationMethod),
112+
string(challType),
93113
remoteCAAResults)
94114

95115
// If the remote result was a non-nil problem then fail the CAA check
96116
if remoteProb != nil {
97117
prob = remoteProb
98-
// We only set .Error here, not InternalError, because the remote VA doesn't send
99-
// us the internal error. But that's okay, because it got logged at the remote VA.
100-
logEvent.Error = remoteProb.Error()
101-
checkResult = "failure"
102118
va.log.Infof("CAA check failed due to remote failures: identifier=%v err=%s",
103119
req.Domain, remoteProb)
104-
va.metrics.remoteCAACheckFailures.Inc()
105120
}
106121
}
107122
}
108-
checkLatency := time.Since(checkStartTime)
109-
logEvent.ValidationLatency = checkLatency.Round(time.Millisecond).Seconds()
110-
111-
va.metrics.localCAACheckTime.With(prometheus.Labels{
112-
"result": checkResult,
113-
}).Observe(localCheckLatency.Seconds())
114-
va.metrics.caaCheckTime.With(prometheus.Labels{
115-
"result": checkResult,
116-
}).Observe(checkLatency.Seconds())
117-
118-
va.log.AuditObject("CAA check result", logEvent)
119123

120124
if prob != nil {
121125
// The ProblemDetails will be serialized through gRPC, which requires UTF-8.
@@ -154,15 +158,6 @@ func (va *ValidationAuthorityImpl) processRemoteCAAResults(
154158
challengeType string,
155159
remoteResultsChan <-chan *remoteVAResult) *probs.ProblemDetails {
156160

157-
state := "failure"
158-
start := va.clk.Now()
159-
160-
defer func() {
161-
va.metrics.remoteCAACheckTime.With(prometheus.Labels{
162-
"result": state,
163-
}).Observe(va.clk.Since(start).Seconds())
164-
}()
165-
166161
required := len(va.remoteVAs) - va.maxRemoteFailures
167162
good := 0
168163
bad := 0
@@ -190,7 +185,6 @@ func (va *ValidationAuthorityImpl) processRemoteCAAResults(
190185
// success or failure threshold is met.
191186
if !features.Get().MultiCAAFullResults {
192187
if good >= required {
193-
state = "success"
194188
return nil
195189
} else if bad > va.maxRemoteFailures {
196190
modifiedProblem := *result.Problem
@@ -217,7 +211,6 @@ func (va *ValidationAuthorityImpl) processRemoteCAAResults(
217211

218212
// Based on the threshold of good/bad return nil or a problem.
219213
if good >= required {
220-
state = "success"
221214
return nil
222215
} else if bad > va.maxRemoteFailures {
223216
modifiedProblem := *firstProb

0 commit comments

Comments
 (0)