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) {
|
func authzMetaToPB(authz core.Authorization) (*vapb.AuthzMeta, error) {
|
||||||
return &vapb.AuthzMeta{
|
return &vapb.AuthzMeta{
|
||||||
Id: &authz.ID,
|
Id: authz.ID,
|
||||||
RegID: &authz.RegistrationID,
|
RegID: authz.RegistrationID,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func pbToAuthzMeta(in *vapb.AuthzMeta) (core.Authorization, error) {
|
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{}, ErrMissingParameters
|
||||||
}
|
}
|
||||||
return core.Authorization{
|
return core.Authorization{
|
||||||
ID: *in.Id,
|
ID: in.Id,
|
||||||
RegistrationID: *in.RegID,
|
RegistrationID: in.RegID,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,11 +228,11 @@ func performValidationReqToArgs(in *vapb.PerformValidationRequest) (domain strin
|
||||||
err = ErrMissingParameters
|
err = ErrMissingParameters
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if in.Domain == nil {
|
if in.Domain == "" {
|
||||||
err = ErrMissingParameters
|
err = ErrMissingParameters
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
domain = *in.Domain
|
domain = in.Domain
|
||||||
challenge, err = pbToChallenge(in.Challenge)
|
challenge, err = pbToChallenge(in.Challenge)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
@ -255,7 +255,7 @@ func argsToPerformValidationRequest(domain string, challenge core.Challenge, aut
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &vapb.PerformValidationRequest{
|
return &vapb.PerformValidationRequest{
|
||||||
Domain: &domain,
|
Domain: domain,
|
||||||
Challenge: pbChall,
|
Challenge: pbChall,
|
||||||
Authz: authzMeta,
|
Authz: authzMeta,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@ func TestAuthzMeta(t *testing.T) {
|
||||||
pb, err := authzMetaToPB(authz)
|
pb, err := authzMetaToPB(authz)
|
||||||
test.AssertNotError(t, err, "authzMetaToPB failed")
|
test.AssertNotError(t, err, "authzMetaToPB failed")
|
||||||
test.Assert(t, pb != nil, "return vapb.AuthzMeta is nill")
|
test.Assert(t, pb != nil, "return vapb.AuthzMeta is nill")
|
||||||
test.Assert(t, pb.Id != nil, "Id field is nil")
|
test.Assert(t, pb.Id != "", "Id field is not set")
|
||||||
test.AssertEquals(t, *pb.Id, authz.ID)
|
test.AssertEquals(t, pb.Id, authz.ID)
|
||||||
test.Assert(t, pb.RegID != nil, "RegistrationID field is nil")
|
test.Assert(t, pb.RegID != 0, "RegistrationID field is not set")
|
||||||
test.AssertEquals(t, *pb.RegID, authz.RegistrationID)
|
test.AssertEquals(t, pb.RegID, authz.RegistrationID)
|
||||||
|
|
||||||
recon, err := pbToAuthzMeta(pb)
|
recon, err := pbToAuthzMeta(pb)
|
||||||
test.AssertNotError(t, err, "pbToAuthzMeta failed")
|
test.AssertNotError(t, err, "pbToAuthzMeta failed")
|
||||||
|
|
@ -37,12 +37,10 @@ func TestAuthzMeta(t *testing.T) {
|
||||||
_, err = pbToAuthzMeta(&vapb.AuthzMeta{})
|
_, err = pbToAuthzMeta(&vapb.AuthzMeta{})
|
||||||
test.AssertError(t, err, "pbToAuthzMeta did not fail")
|
test.AssertError(t, err, "pbToAuthzMeta did not fail")
|
||||||
test.AssertEquals(t, err, ErrMissingParameters)
|
test.AssertEquals(t, err, ErrMissingParameters)
|
||||||
empty := ""
|
_, err = pbToAuthzMeta(&vapb.AuthzMeta{Id: ""})
|
||||||
one := int64(1)
|
|
||||||
_, err = pbToAuthzMeta(&vapb.AuthzMeta{Id: &empty})
|
|
||||||
test.AssertError(t, err, "pbToAuthzMeta did not fail")
|
test.AssertError(t, err, "pbToAuthzMeta did not fail")
|
||||||
test.AssertEquals(t, err, ErrMissingParameters)
|
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.AssertError(t, err, "pbToAuthzMeta did not fail")
|
||||||
test.AssertEquals(t, err, ErrMissingParameters)
|
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{
|
resp, err := ra.caa.IsCAAValid(ctx, &vaPB.IsCAAValidRequest{
|
||||||
Domain: &name,
|
Domain: name,
|
||||||
ValidationMethod: &method,
|
ValidationMethod: method,
|
||||||
AccountURIID: &authz.RegistrationID,
|
AccountURIID: authz.RegistrationID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ra.log.AuditErrf("Rechecking CAA: %s", err)
|
ra.log.AuditErrf("Rechecking CAA: %s", err)
|
||||||
|
|
|
||||||
|
|
@ -1780,7 +1780,7 @@ func (cr *caaRecorder) IsCAAValid(
|
||||||
) (*vaPB.IsCAAValidResponse, error) {
|
) (*vaPB.IsCAAValidResponse, error) {
|
||||||
cr.Lock()
|
cr.Lock()
|
||||||
defer cr.Unlock()
|
defer cr.Unlock()
|
||||||
cr.names[*in.Domain] = true
|
cr.names[in.Domain] = true
|
||||||
return &vaPB.IsCAAValidResponse{}, nil
|
return &vaPB.IsCAAValidResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1899,7 +1899,7 @@ func (cf *caaFailer) IsCAAValid(
|
||||||
opts ...grpc.CallOption,
|
opts ...grpc.CallOption,
|
||||||
) (*vaPB.IsCAAValidResponse, error) {
|
) (*vaPB.IsCAAValidResponse, error) {
|
||||||
cvrpb := &vaPB.IsCAAValidResponse{}
|
cvrpb := &vaPB.IsCAAValidResponse{}
|
||||||
switch *in.Domain {
|
switch in.Domain {
|
||||||
case "a.com":
|
case "a.com":
|
||||||
cvrpb.Problem = &corepb.ProblemDetails{
|
cvrpb.Problem = &corepb.ProblemDetails{
|
||||||
Detail: proto.String("CAA invalid for a.com"),
|
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) {
|
func (va *ValidationAuthorityImpl) IsCAAValid(ctx context.Context, req *vapb.IsCAAValidRequest) (*vapb.IsCAAValidResponse, error) {
|
||||||
acmeID := identifier.ACMEIdentifier{
|
acmeID := identifier.ACMEIdentifier{
|
||||||
Type: identifier.DNS,
|
Type: identifier.DNS,
|
||||||
Value: *req.Domain,
|
Value: req.Domain,
|
||||||
}
|
}
|
||||||
params := &caaParams{
|
params := &caaParams{
|
||||||
accountURIID: req.AccountURIID,
|
accountURIID: &req.AccountURIID,
|
||||||
validationMethod: req.ValidationMethod,
|
validationMethod: &req.ValidationMethod,
|
||||||
}
|
}
|
||||||
if prob := va.checkCAA(ctx, acmeID, params); prob != nil {
|
if prob := va.checkCAA(ctx, acmeID, params); prob != nil {
|
||||||
typ := string(prob.Type)
|
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{
|
return &vapb.IsCAAValidResponse{
|
||||||
Problem: &corepb.ProblemDetails{
|
Problem: &corepb.ProblemDetails{
|
||||||
ProblemType: &typ,
|
ProblemType: &typ,
|
||||||
|
|
|
||||||
|
|
@ -565,7 +565,7 @@ func TestIsCAAValidErrMessage(t *testing.T) {
|
||||||
// caaMockDNS.
|
// caaMockDNS.
|
||||||
domain := "caa-timeout.com"
|
domain := "caa-timeout.com"
|
||||||
resp, err := va.IsCAAValid(ctx, &vapb.IsCAAValidRequest{
|
resp, err := va.IsCAAValid(ctx, &vapb.IsCAAValidRequest{
|
||||||
Domain: &domain,
|
Domain: domain,
|
||||||
})
|
})
|
||||||
|
|
||||||
// The lookup itself should not return an error
|
// The lookup itself should not return an error
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,9 @@ type IsCAAValidRequest struct {
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
// NOTE: Domain may be a name with a wildcard prefix (e.g. `*.example.com`)
|
// 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"`
|
Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"`
|
||||||
ValidationMethod *string `protobuf:"bytes,2,opt,name=validationMethod" json:"validationMethod,omitempty"`
|
ValidationMethod string `protobuf:"bytes,2,opt,name=validationMethod,proto3" json:"validationMethod,omitempty"`
|
||||||
AccountURIID *int64 `protobuf:"varint,3,opt,name=accountURIID" json:"accountURIID,omitempty"`
|
AccountURIID int64 `protobuf:"varint,3,opt,name=accountURIID,proto3" json:"accountURIID,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IsCAAValidRequest) Reset() {
|
func (x *IsCAAValidRequest) Reset() {
|
||||||
|
|
@ -74,22 +74,22 @@ func (*IsCAAValidRequest) Descriptor() ([]byte, []int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IsCAAValidRequest) GetDomain() string {
|
func (x *IsCAAValidRequest) GetDomain() string {
|
||||||
if x != nil && x.Domain != nil {
|
if x != nil {
|
||||||
return *x.Domain
|
return x.Domain
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IsCAAValidRequest) GetValidationMethod() string {
|
func (x *IsCAAValidRequest) GetValidationMethod() string {
|
||||||
if x != nil && x.ValidationMethod != nil {
|
if x != nil {
|
||||||
return *x.ValidationMethod
|
return x.ValidationMethod
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IsCAAValidRequest) GetAccountURIID() int64 {
|
func (x *IsCAAValidRequest) GetAccountURIID() int64 {
|
||||||
if x != nil && x.AccountURIID != nil {
|
if x != nil {
|
||||||
return *x.AccountURIID
|
return x.AccountURIID
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
@ -100,7 +100,7 @@ type IsCAAValidResponse struct {
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
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() {
|
func (x *IsCAAValidResponse) Reset() {
|
||||||
|
|
@ -147,9 +147,9 @@ type PerformValidationRequest struct {
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Domain *string `protobuf:"bytes,1,opt,name=domain" json:"domain,omitempty"`
|
Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"`
|
||||||
Challenge *proto1.Challenge `protobuf:"bytes,2,opt,name=challenge" json:"challenge,omitempty"`
|
Challenge *proto1.Challenge `protobuf:"bytes,2,opt,name=challenge,proto3" json:"challenge,omitempty"`
|
||||||
Authz *AuthzMeta `protobuf:"bytes,3,opt,name=authz" json:"authz,omitempty"`
|
Authz *AuthzMeta `protobuf:"bytes,3,opt,name=authz,proto3" json:"authz,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PerformValidationRequest) Reset() {
|
func (x *PerformValidationRequest) Reset() {
|
||||||
|
|
@ -185,8 +185,8 @@ func (*PerformValidationRequest) Descriptor() ([]byte, []int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PerformValidationRequest) GetDomain() string {
|
func (x *PerformValidationRequest) GetDomain() string {
|
||||||
if x != nil && x.Domain != nil {
|
if x != nil {
|
||||||
return *x.Domain
|
return x.Domain
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
@ -210,8 +210,8 @@ type AuthzMeta struct {
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Id *string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
RegID *int64 `protobuf:"varint,2,opt,name=regID" json:"regID,omitempty"`
|
RegID int64 `protobuf:"varint,2,opt,name=regID,proto3" json:"regID,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AuthzMeta) Reset() {
|
func (x *AuthzMeta) Reset() {
|
||||||
|
|
@ -247,15 +247,15 @@ func (*AuthzMeta) Descriptor() ([]byte, []int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AuthzMeta) GetId() string {
|
func (x *AuthzMeta) GetId() string {
|
||||||
if x != nil && x.Id != nil {
|
if x != nil {
|
||||||
return *x.Id
|
return x.Id
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AuthzMeta) GetRegID() int64 {
|
func (x *AuthzMeta) GetRegID() int64 {
|
||||||
if x != nil && x.RegID != nil {
|
if x != nil {
|
||||||
return *x.RegID
|
return x.RegID
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
@ -265,8 +265,8 @@ type ValidationResult struct {
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Records []*proto1.ValidationRecord `protobuf:"bytes,1,rep,name=records" json:"records,omitempty"`
|
Records []*proto1.ValidationRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"`
|
||||||
Problems *proto1.ProblemDetails `protobuf:"bytes,2,opt,name=problems" json:"problems,omitempty"`
|
Problems *proto1.ProblemDetails `protobuf:"bytes,2,opt,name=problems,proto3" json:"problems,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ValidationResult) Reset() {
|
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,
|
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,
|
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,
|
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 (
|
var (
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
syntax = "proto2";
|
syntax = "proto3";
|
||||||
|
|
||||||
package va;
|
package va;
|
||||||
option go_package = "github.com/letsencrypt/boulder/va/proto";
|
option go_package = "github.com/letsencrypt/boulder/va/proto";
|
||||||
|
|
@ -15,28 +15,28 @@ service CAA {
|
||||||
|
|
||||||
message IsCAAValidRequest {
|
message IsCAAValidRequest {
|
||||||
// NOTE: Domain may be a name with a wildcard prefix (e.g. `*.example.com`)
|
// NOTE: Domain may be a name with a wildcard prefix (e.g. `*.example.com`)
|
||||||
optional string domain = 1;
|
string domain = 1;
|
||||||
optional string validationMethod = 2;
|
string validationMethod = 2;
|
||||||
optional int64 accountURIID = 3;
|
int64 accountURIID = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If CAA is valid for the requested domain, the problem will be empty
|
// If CAA is valid for the requested domain, the problem will be empty
|
||||||
message IsCAAValidResponse {
|
message IsCAAValidResponse {
|
||||||
optional core.ProblemDetails problem = 1;
|
core.ProblemDetails problem = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PerformValidationRequest {
|
message PerformValidationRequest {
|
||||||
optional string domain = 1;
|
string domain = 1;
|
||||||
optional core.Challenge challenge = 2;
|
core.Challenge challenge = 2;
|
||||||
optional AuthzMeta authz = 3;
|
AuthzMeta authz = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message AuthzMeta {
|
message AuthzMeta {
|
||||||
optional string id = 1;
|
string id = 1;
|
||||||
optional int64 regID = 2;
|
int64 regID = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ValidationResult {
|
message ValidationResult {
|
||||||
repeated core.ValidationRecord records = 1;
|
repeated core.ValidationRecord records = 1;
|
||||||
optional core.ProblemDetails problems = 2;
|
core.ProblemDetails problems = 2;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue