Improve SCEP API logic and error handling

This commit is contained in:
Herman Slatman 2021-02-27 00:34:50 +01:00 committed by max furman
parent 30d3a26c20
commit a191319da9
4 changed files with 145 additions and 103 deletions

View file

@ -11,6 +11,7 @@ import (
"github.com/smallstep/certificates/authority/mgmt"
"github.com/smallstep/certificates/errs"
"github.com/smallstep/certificates/logging"
"github.com/smallstep/certificates/scep"
)
// WriteError writes to w a JSON representation of the given error.
@ -22,6 +23,8 @@ func WriteError(w http.ResponseWriter, err error) {
case *mgmt.Error:
mgmt.WriteError(w, k)
return
case *scep.Error:
w.Header().Set("Content-Type", "text/plain")
default:
w.Header().Set("Content-Type", "application/json")
}