|
@@ -383,17 +383,6 @@ func badRequest(format string, args ...interface{}) error {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TODO(mariano): refactor errs package to allow sending real errors to the
|
|
|
|
|
-// user.
|
|
|
|
|
-func unauthorized(format string, args ...interface{}) error {
|
|
|
|
|
- msg := fmt.Sprintf(format, args...)
|
|
|
|
|
- return &errs.Error{
|
|
|
|
|
- Status: http.StatusUnauthorized,
|
|
|
|
|
- Msg: msg,
|
|
|
|
|
- Err: errors.New(msg),
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// Valid validates the certificate validity settings (notBefore/notAfter) and
|
|
// Valid validates the certificate validity settings (notBefore/notAfter) and
|
|
|
// and total duration.
|
|
// and total duration.
|
|
|
func (v *validityValidator) Valid(cert *x509.Certificate, o SignOptions) error {
|
|
func (v *validityValidator) Valid(cert *x509.Certificate, o SignOptions) error {
|
|
@@ -412,14 +401,14 @@ func (v *validityValidator) Valid(cert *x509.Certificate, o SignOptions) error {
|
|
|
return badRequest("notAfter cannot be before notBefore; na=%v, nb=%v", na, nb)
|
|
return badRequest("notAfter cannot be before notBefore; na=%v, nb=%v", na, nb)
|
|
|
}
|
|
}
|
|
|
if d < v.min {
|
|
if d < v.min {
|
|
|
- return unauthorized("requested duration of %v is less than the authorized minimum certificate duration of %v", d, v.min)
|
|
|
|
|
|
|
+ return badRequest("requested duration of %v is less than the authorized minimum certificate duration of %v", d, v.min)
|
|
|
}
|
|
}
|
|
|
// NOTE: this check is not "technically correct". We're allowing the max
|
|
// NOTE: this check is not "technically correct". We're allowing the max
|
|
|
// duration of a cert to be "max + backdate" and not all certificates will
|
|
// duration of a cert to be "max + backdate" and not all certificates will
|
|
|
// be backdated (e.g. if a user passes the NotBefore value then we do not
|
|
// be backdated (e.g. if a user passes the NotBefore value then we do not
|
|
|
// apply a backdate). This is good enough.
|
|
// apply a backdate). This is good enough.
|
|
|
if d > v.max+o.Backdate {
|
|
if d > v.max+o.Backdate {
|
|
|
- return unauthorized("requested duration of %v is more than the authorized maximum certificate duration of %v", d, v.max+o.Backdate)
|
|
|
|
|
|
|
+ return badRequest("requested duration of %v is more than the authorized maximum certificate duration of %v", d, v.max+o.Backdate)
|
|
|
}
|
|
}
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|