Skip to content

Commit

Permalink
VA: Add a method for performing MPIC compliant challenge validation
Browse files Browse the repository at this point in the history
  • Loading branch information
beautifulentropy committed Nov 8, 2024
1 parent 3377102 commit 29dee31
Show file tree
Hide file tree
Showing 14 changed files with 1,044 additions and 122 deletions.
18 changes: 0 additions & 18 deletions core/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,6 @@ type ValidationRecord struct {
// lookup for AddressUsed. During recursive A and AAAA lookups, a record may
// instead look like A:host:port or AAAA:host:port
ResolverAddrs []string `json:"resolverAddrs,omitempty"`

// Perspective uniquely identifies the Network Perspective used to perform
// the validation, as specified in BRs Section 5.4.1, Requirement 2.7
// ("Multi-Perspective Issuance Corroboration attempts from each Network
// Perspective"). It should uniquely identify either the Primary Perspective
// (VA) or a group of RVAs deployed in the same datacenter.
Perspective string `json:"perspective,omitempty"`

// RIR indicates the Regional Internet Registry where this RVA is located.
// This field is used to identify the RIR region from which a given
// validation was performed, as specified in the "Phased Implementation
// Timeline" in BRs Section 3.2.2.9. It must be one of the following values:
// - ARIN
// - RIPE
// - APNIC
// - LACNIC
// - AfriNIC
RIR string `json:"rir,omitempty"`
}

// Challenge is an aggregate of all data needed for any challenges.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/letsencrypt/boulder

go 1.22.0
go 1.23.0

require (
github.com/aws/aws-sdk-go-v2 v1.32.2
Expand Down
8 changes: 5 additions & 3 deletions grpc/pb-marshalling.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func PBToValidationRecord(in *corepb.ValidationRecord) (record core.ValidationRe
}, nil
}

func ValidationResultToPB(records []core.ValidationRecord, prob *probs.ProblemDetails) (*vapb.ValidationResult, error) {
func ValidationResultToPB(records []core.ValidationRecord, prob *probs.ProblemDetails, perspective, rir string) (*vapb.ValidationResult, error) {
recordAry := make([]*corepb.ValidationRecord, len(records))
var err error
for i, v := range records {
Expand All @@ -193,8 +193,10 @@ func ValidationResultToPB(records []core.ValidationRecord, prob *probs.ProblemDe
return nil, err
}
return &vapb.ValidationResult{
Records: recordAry,
Problems: marshalledProbs,
Records: recordAry,
Problems: marshalledProbs,
Perspective: perspective,
Rir: rir,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion grpc/pb-marshalling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestValidationResult(t *testing.T) {
result := []core.ValidationRecord{vrA, vrB}
prob := &probs.ProblemDetails{Type: probs.TLSProblem, Detail: "asd", HTTPStatus: 200}

pb, err := ValidationResultToPB(result, prob)
pb, err := ValidationResultToPB(result, prob, "", "")
test.AssertNotError(t, err, "ValidationResultToPB failed")
test.Assert(t, pb != nil, "Returned vapb.ValidationResult is nil")

Expand Down
2 changes: 1 addition & 1 deletion ra/ra.go
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,7 @@ func (ra *RegistrationAuthorityImpl) recordValidation(ctx context.Context, authI
} else {
expires = ra.clk.Now().Add(ra.authorizationLifetime)
}
vr, err := bgrpc.ValidationResultToPB(challenge.ValidationRecord, challenge.Error)
vr, err := bgrpc.ValidationResultToPB(challenge.ValidationRecord, challenge.Error, "", "")
if err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions ra/ra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ func (dva *DummyValidationAuthority) PerformValidation(ctx context.Context, req
return dva.PerformValidationRequestResultReturn, dva.PerformValidationRequestResultError
}

func (dva *DummyValidationAuthority) ValidateChallenge(ctx context.Context, req *vapb.ValidationRequest, _ ...grpc.CallOption) (*vapb.ValidationResult, error) {
return nil, status.Error(codes.Unimplemented, "not implemented")
}

var (
// These values we simulate from the client
AccountKeyJSONA = []byte(`{
Expand Down
8 changes: 4 additions & 4 deletions va/caa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ func (b caaBrokenDNS) LookupCAA(_ context.Context, domain string) ([]*dns.CAA, s
}

func TestDisabledMultiCAARechecking(t *testing.T) {
brokenRVA, _ := setupRemote(nil, "broken", caaBrokenDNS{}, "", "")
brokenRVA, _ := setupRemote(nil, "broken", caaBrokenDNS{})
remoteVAs := []RemoteVA{{brokenRVA, "broken"}}
va, _ := setup(nil, 0, "local", remoteVAs, nil)

Expand Down Expand Up @@ -663,10 +663,10 @@ func TestMultiCAARechecking(t *testing.T) {
brokenUA = "broken"
hijackedUA = "hijacked"
)
remoteVA, _ := setupRemote(nil, remoteUA, nil, "", "")
brokenVA, _ := setupRemote(nil, brokenUA, caaBrokenDNS{}, "", "")
remoteVA, _ := setupRemote(nil, remoteUA, nil)
brokenVA, _ := setupRemote(nil, brokenUA, caaBrokenDNS{})
// Returns incorrect results
hijackedVA, _ := setupRemote(nil, hijackedUA, caaHijackedDNS{}, "", "")
hijackedVA, _ := setupRemote(nil, hijackedUA, caaHijackedDNS{})

testCases := []struct {
name string
Expand Down
2 changes: 1 addition & 1 deletion va/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestDNSValidationEmpty(t *testing.T) {

// This test calls PerformValidation directly, because that is where the
// metrics checked below are incremented.
req := createValidationRequest("empty-txts.com", core.ChallengeTypeDNS01)
req := createPerformValidationRequest("empty-txts.com", core.ChallengeTypeDNS01)
res, _ := va.PerformValidation(context.Background(), req)
test.AssertEquals(t, res.Problems.ProblemType, "unauthorized")
test.AssertEquals(t, res.Problems.Detail, "No TXT record found at _acme-challenge.empty-txts.com")
Expand Down
181 changes: 148 additions & 33 deletions va/proto/va.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions va/proto/va.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "core/proto/core.proto";

service VA {
rpc PerformValidation(PerformValidationRequest) returns (ValidationResult) {}
rpc ValidateChallenge(ValidationRequest) returns (ValidationResult) {}
}

service CAA {
Expand Down Expand Up @@ -43,3 +44,11 @@ message ValidationResult {
string perspective = 3;
string rir = 4;
}

message ValidationRequest {
core.Identifier identifier = 1;
core.Challenge challenge = 2;
int64 regID = 3;
string authzID = 4;
string keyAuthorization = 5;
}
Loading

0 comments on commit 29dee31

Please sign in to comment.