Switch VA RPCs to proto3 (#4960)
This updates va.proto to use proto3 syntax, and updates all clients of the autogenerated code to use the new types. In particular, it removes indirection from built-in types (proto3 uses ints, rather than pointers to ints, for example). Fixes #4956
This commit is contained in:
parent
440c5f96d9
commit
281575433b
|
|
@ -27,18 +27,18 @@ var ErrMissingParameters = CodedError(codes.FailedPrecondition, "required RPC pa
|
|||
|
||||
func authzMetaToPB(authz core.Authorization) (*vapb.AuthzMeta, error) {
|
||||
return &vapb.AuthzMeta{
|
||||
Id: &authz.ID,
|
||||
RegID: &authz.RegistrationID,
|
||||
Id: authz.ID,
|
||||
RegID: authz.RegistrationID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func pbToAuthzMeta(in *vapb.AuthzMeta) (core.Authorization, error) {
|
||||
if in == nil || in.Id == nil || in.RegID == nil {
|
||||
if in == nil || in.Id == "" || in.RegID == 0 {
|
||||
return core.Authorization{}, ErrMissingParameters
|
||||
}
|
||||
return core.Authorization{
|
||||
ID: *in.Id,
|
||||
RegistrationID: *in.RegID,
|
||||
ID: in.Id,
|
||||
RegistrationID: in.RegID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
@ -228,11 +228,11 @@ func performValidationReqToArgs(in *vapb.PerformValidationRequest) (domain strin
|
|||
err = ErrMissingParameters
|
||||
return
|
||||
}
|
||||
if in.Domain == nil {
|
||||
if in.Domain == "" {
|
||||
err = ErrMissingParameters
|
||||
return
|
||||
}
|
||||
domain = *in.Domain
|
||||
domain = in.Domain
|
||||
challenge, err = pbToChallenge(in.Challenge)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -255,7 +255,7 @@ func argsToPerformValidationRequest(domain string, challenge core.Challenge, aut
|
|||
return nil, err
|
||||
}
|
||||
return &vapb.PerformValidationRequest{
|
||||
Domain: &domain,
|
||||
Domain: domain,
|
||||
Challenge: pbChall,
|
||||
Authz: authzMeta,
|
||||
}, nil
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ func TestAuthzMeta(t *testing.T) {
|
|||
pb, err := authzMetaToPB(authz)
|
||||
test.AssertNotError(t, err, "authzMetaToPB failed")
|
||||
test.Assert(t, pb != nil, "return vapb.AuthzMeta is nill")
|
||||
test.Assert(t, pb.Id != nil, "Id field is nil")
|
||||
test.AssertEquals(t, *pb.Id, authz.ID)
|
||||
test.Assert(t, pb.RegID != nil, "RegistrationID field is nil")
|
||||
test.AssertEquals(t, *pb.RegID, authz.RegistrationID)
|
||||
test.Assert(t, pb.Id != "", "Id field is not set")
|
||||
test.AssertEquals(t, pb.Id, authz.ID)
|
||||
test.Assert(t, pb.RegID != 0, "RegistrationID field is not set")
|
||||
test.AssertEquals(t, pb.RegID, authz.RegistrationID)
|
||||
|
||||
recon, err := pbToAuthzMeta(pb)
|
||||
test.AssertNotError(t, err, "pbToAuthzMeta failed")
|
||||
|
|
@ -37,12 +37,10 @@ func TestAuthzMeta(t *testing.T) {
|
|||
_, err = pbToAuthzMeta(&vapb.AuthzMeta{})
|
||||
test.AssertError(t, err, "pbToAuthzMeta did not fail")
|
||||
test.AssertEquals(t, err, ErrMissingParameters)
|
||||
empty := ""
|
||||
one := int64(1)
|
||||
_, err = pbToAuthzMeta(&vapb.AuthzMeta{Id: &empty})
|
||||
_, err = pbToAuthzMeta(&vapb.AuthzMeta{Id: ""})
|
||||
test.AssertError(t, err, "pbToAuthzMeta did not fail")
|
||||
test.AssertEquals(t, err, ErrMissingParameters)
|
||||
_, err = pbToAuthzMeta(&vapb.AuthzMeta{RegID: &one})
|
||||
_, err = pbToAuthzMeta(&vapb.AuthzMeta{RegID: int64(1)})
|
||||
test.AssertError(t, err, "pbToAuthzMeta did not fail")
|
||||
test.AssertEquals(t, err, ErrMissingParameters)
|
||||
}
|
||||
|
|
|
|||
6
ra/ra.go
6
ra/ra.go
|
|
@ -848,9 +848,9 @@ func (ra *RegistrationAuthorityImpl) recheckCAA(ctx context.Context, authzs []*c
|
|||
}
|
||||
|
||||
resp, err := ra.caa.IsCAAValid(ctx, &vaPB.IsCAAValidRequest{
|
||||
Domain: &name,
|
||||
ValidationMethod: &method,
|
||||
AccountURIID: &authz.RegistrationID,
|
||||
Domain: name,
|
||||
ValidationMethod: method,
|
||||
AccountURIID: authz.RegistrationID,
|
||||
})
|
||||
if err != nil {
|
||||
ra.log.AuditErrf("Rechecking CAA: %s", err)
|
||||
|
|
|
|||
|
|
@ -1780,7 +1780,7 @@ func (cr *caaRecorder) IsCAAValid(
|
|||
) (*vaPB.IsCAAValidResponse, error) {
|
||||
cr.Lock()
|
||||
defer cr.Unlock()
|
||||
cr.names[*in.Domain] = true
|
||||
cr.names[in.Domain] = true
|
||||
return &vaPB.IsCAAValidResponse{}, nil
|
||||
}
|
||||
|
||||
|
|
@ -1899,7 +1899,7 @@ func (cf *caaFailer) IsCAAValid(
|
|||
opts ...grpc.CallOption,
|
||||
) (*vaPB.IsCAAValidResponse, error) {
|
||||
cvrpb := &vaPB.IsCAAValidResponse{}
|
||||
switch *in.Domain {
|
||||
switch in.Domain {
|
||||
case "a.com":
|
||||
cvrpb.Problem = &corepb.ProblemDetails{
|
||||
Detail: proto.String("CAA invalid for a.com"),
|
||||
|
|
|
|||
|
|
@ -23,15 +23,15 @@ type caaParams struct {
|
|||
func (va *ValidationAuthorityImpl) IsCAAValid(ctx context.Context, req *vapb.IsCAAValidRequest) (*vapb.IsCAAValidResponse, error) {
|
||||
acmeID := identifier.ACMEIdentifier{
|
||||
Type: identifier.DNS,
|
||||
Value: *req.Domain,
|
||||
Value: req.Domain,
|
||||
}
|
||||
params := &caaParams{
|
||||
accountURIID: req.AccountURIID,
|
||||
validationMethod: req.ValidationMethod,
|
||||
accountURIID: &req.AccountURIID,
|
||||
validationMethod: &req.ValidationMethod,
|
||||
}
|
||||
if prob := va.checkCAA(ctx, acmeID, params); prob != nil {
|
||||
typ := string(prob.Type)
|
||||
detail := fmt.Sprintf("While processing CAA for %s: %s", *req.Domain, prob.Detail)
|
||||
detail := fmt.Sprintf("While processing CAA for %s: %s", req.Domain, prob.Detail)
|
||||
return &vapb.IsCAAValidResponse{
|
||||
Problem: &corepb.ProblemDetails{
|
||||
ProblemType: &typ,
|
||||
|
|
|
|||
|
|
@ -565,7 +565,7 @@ func TestIsCAAValidErrMessage(t *testing.T) {
|
|||
// caaMockDNS.
|
||||
domain := "caa-timeout.com"
|
||||
resp, err := va.IsCAAValid(ctx, &vapb.IsCAAValidRequest{
|
||||
Domain: &domain,
|
||||
Domain: domain,
|
||||
})
|
||||
|
||||
// The lookup itself should not return an error
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ type IsCAAValidRequest struct {
|
|||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// NOTE: Domain may be a name with a wildcard prefix (e.g. `*.example.com`)
|
||||
Domain *string `protobuf:"bytes,1,opt,name=domain" json:"domain,omitempty"`
|
||||
ValidationMethod *string `protobuf:"bytes,2,opt,name=validationMethod" json:"validationMethod,omitempty"`
|
||||
AccountURIID *int64 `protobuf:"varint,3,opt,name=accountURIID" json:"accountURIID,omitempty"`
|
||||
Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"`
|
||||
ValidationMethod string `protobuf:"bytes,2,opt,name=validationMethod,proto3" json:"validationMethod,omitempty"`
|
||||
AccountURIID int64 `protobuf:"varint,3,opt,name=accountURIID,proto3" json:"accountURIID,omitempty"`
|
||||
}
|
||||
|
||||
func (x *IsCAAValidRequest) Reset() {
|
||||
|
|
@ -74,22 +74,22 @@ func (*IsCAAValidRequest) Descriptor() ([]byte, []int) {
|
|||
}
|
||||
|
||||
func (x *IsCAAValidRequest) GetDomain() string {
|
||||
if x != nil && x.Domain != nil {
|
||||
return *x.Domain
|
||||
if x != nil {
|
||||
return x.Domain
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *IsCAAValidRequest) GetValidationMethod() string {
|
||||
if x != nil && x.ValidationMethod != nil {
|
||||
return *x.ValidationMethod
|
||||
if x != nil {
|
||||
return x.ValidationMethod
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *IsCAAValidRequest) GetAccountURIID() int64 {
|
||||
if x != nil && x.AccountURIID != nil {
|
||||
return *x.AccountURIID
|
||||
if x != nil {
|
||||
return x.AccountURIID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ type IsCAAValidResponse struct {
|
|||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Problem *proto1.ProblemDetails `protobuf:"bytes,1,opt,name=problem" json:"problem,omitempty"`
|
||||
Problem *proto1.ProblemDetails `protobuf:"bytes,1,opt,name=problem,proto3" json:"problem,omitempty"`
|
||||
}
|
||||
|
||||
func (x *IsCAAValidResponse) Reset() {
|
||||
|
|
@ -147,9 +147,9 @@ type PerformValidationRequest struct {
|
|||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Domain *string `protobuf:"bytes,1,opt,name=domain" json:"domain,omitempty"`
|
||||
Challenge *proto1.Challenge `protobuf:"bytes,2,opt,name=challenge" json:"challenge,omitempty"`
|
||||
Authz *AuthzMeta `protobuf:"bytes,3,opt,name=authz" json:"authz,omitempty"`
|
||||
Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"`
|
||||
Challenge *proto1.Challenge `protobuf:"bytes,2,opt,name=challenge,proto3" json:"challenge,omitempty"`
|
||||
Authz *AuthzMeta `protobuf:"bytes,3,opt,name=authz,proto3" json:"authz,omitempty"`
|
||||
}
|
||||
|
||||
func (x *PerformValidationRequest) Reset() {
|
||||
|
|
@ -185,8 +185,8 @@ func (*PerformValidationRequest) Descriptor() ([]byte, []int) {
|
|||
}
|
||||
|
||||
func (x *PerformValidationRequest) GetDomain() string {
|
||||
if x != nil && x.Domain != nil {
|
||||
return *x.Domain
|
||||
if x != nil {
|
||||
return x.Domain
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
@ -210,8 +210,8 @@ type AuthzMeta struct {
|
|||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id *string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
||||
RegID *int64 `protobuf:"varint,2,opt,name=regID" json:"regID,omitempty"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
RegID int64 `protobuf:"varint,2,opt,name=regID,proto3" json:"regID,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AuthzMeta) Reset() {
|
||||
|
|
@ -247,15 +247,15 @@ func (*AuthzMeta) Descriptor() ([]byte, []int) {
|
|||
}
|
||||
|
||||
func (x *AuthzMeta) GetId() string {
|
||||
if x != nil && x.Id != nil {
|
||||
return *x.Id
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AuthzMeta) GetRegID() int64 {
|
||||
if x != nil && x.RegID != nil {
|
||||
return *x.RegID
|
||||
if x != nil {
|
||||
return x.RegID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
|
@ -265,8 +265,8 @@ type ValidationResult struct {
|
|||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Records []*proto1.ValidationRecord `protobuf:"bytes,1,rep,name=records" json:"records,omitempty"`
|
||||
Problems *proto1.ProblemDetails `protobuf:"bytes,2,opt,name=problems" json:"problems,omitempty"`
|
||||
Records []*proto1.ValidationRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"`
|
||||
Problems *proto1.ProblemDetails `protobuf:"bytes,2,opt,name=problems,proto3" json:"problems,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ValidationResult) Reset() {
|
||||
|
|
@ -364,7 +364,7 @@ var file_va_proto_va_proto_rawDesc = []byte{
|
|||
0x69, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x29, 0x5a, 0x27,
|
||||
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x65, 0x74, 0x73, 0x65,
|
||||
0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x2f, 0x62, 0x6f, 0x75, 0x6c, 0x64, 0x65, 0x72, 0x2f, 0x76,
|
||||
0x61, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x61, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
syntax = "proto2";
|
||||
syntax = "proto3";
|
||||
|
||||
package va;
|
||||
option go_package = "github.com/letsencrypt/boulder/va/proto";
|
||||
|
|
@ -15,28 +15,28 @@ service CAA {
|
|||
|
||||
message IsCAAValidRequest {
|
||||
// NOTE: Domain may be a name with a wildcard prefix (e.g. `*.example.com`)
|
||||
optional string domain = 1;
|
||||
optional string validationMethod = 2;
|
||||
optional int64 accountURIID = 3;
|
||||
string domain = 1;
|
||||
string validationMethod = 2;
|
||||
int64 accountURIID = 3;
|
||||
}
|
||||
|
||||
// If CAA is valid for the requested domain, the problem will be empty
|
||||
message IsCAAValidResponse {
|
||||
optional core.ProblemDetails problem = 1;
|
||||
core.ProblemDetails problem = 1;
|
||||
}
|
||||
|
||||
message PerformValidationRequest {
|
||||
optional string domain = 1;
|
||||
optional core.Challenge challenge = 2;
|
||||
optional AuthzMeta authz = 3;
|
||||
string domain = 1;
|
||||
core.Challenge challenge = 2;
|
||||
AuthzMeta authz = 3;
|
||||
}
|
||||
|
||||
message AuthzMeta {
|
||||
optional string id = 1;
|
||||
optional int64 regID = 2;
|
||||
string id = 1;
|
||||
int64 regID = 2;
|
||||
}
|
||||
|
||||
message ValidationResult {
|
||||
repeated core.ValidationRecord records = 1;
|
||||
optional core.ProblemDetails problems = 2;
|
||||
core.ProblemDetails problems = 2;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue