Make validateRequest handling more foolproof

Signed-off-by: Andy Doan <andy@foundries.io>
This commit is contained in:
Andy Doan
2023-12-14 11:51:57 -06:00
parent 583ad2b807
commit a161c54474

View File

@@ -28,7 +28,7 @@ func RegisterEchoHandlers(svcHandler ServiceHandler, e *echo.Echo) {
return c.String(http.StatusInternalServerError, err.Error())
}
bytes, err := validateRequest(svc, c)
if err != nil {
if err != nil || bytes == nil { // validateRequest failed and sent the response
return err
}
bytes, err = svc.Enroll(c.Request().Context(), bytes)
@@ -46,7 +46,7 @@ func RegisterEchoHandlers(svcHandler ServiceHandler, e *echo.Echo) {
return c.String(http.StatusInternalServerError, err.Error())
}
bytes, err := validateRequest(svc, c)
if bytes == nil { // validateRequest failed and sent the response
if err != nil || bytes == nil { // validateRequest failed and sent the response
return err
}
peerCerts := c.Request().TLS.PeerCertificates