Update bad serial error to be more specific

This commit is contained in:
max furman 2022-08-11 09:34:04 -07:00
parent 7052a32c2c
commit 1dd0d7d0ee
2 changed files with 2 additions and 2 deletions

View file

@ -36,7 +36,7 @@ func (r *RevokeRequest) Validate() (err error) {
} }
sn, ok := new(big.Int).SetString(r.Serial, 0) sn, ok := new(big.Int).SetString(r.Serial, 0)
if !ok { if !ok {
return errs.BadRequest("'%s' is not a valid serial number - use a base 10 representation or add a prefix indicating the base", r.Serial) return errs.BadRequest("'%s' is not a valid serial number - use a base 10 representation or a base 16 representation with '0x' prefix", r.Serial)
} }
r.Serial = sn.String() r.Serial = sn.String()
if r.ReasonCode < ocsp.Unspecified || r.ReasonCode > ocsp.AACompromise { if r.ReasonCode < ocsp.Unspecified || r.ReasonCode > ocsp.AACompromise {

View file

@ -33,7 +33,7 @@ func TestRevokeRequestValidate(t *testing.T) {
}, },
"error/bad sn": { "error/bad sn": {
rr: &RevokeRequest{Serial: "sn"}, rr: &RevokeRequest{Serial: "sn"},
err: &errs.Error{Err: errors.New("'sn' is not a valid serial number - use a base 10 representation or add a prefix indicating the base"), Status: http.StatusBadRequest}, err: &errs.Error{Err: errors.New("'sn' is not a valid serial number - use a base 10 representation or a base 16 representation with '0x' prefix"), Status: http.StatusBadRequest},
}, },
"error/bad reasonCode": { "error/bad reasonCode": {
rr: &RevokeRequest{ rr: &RevokeRequest{