@@ -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