Improve SCEP API logic and error handling

This commit is contained in:
Herman Slatman 2021-02-27 00:34:50 +01:00
parent a6d50f2fa0
commit 2fc5a7f22e
No known key found for this signature in database
GPG key ID: F4D8A44EA0A75A4F
4 changed files with 146 additions and 103 deletions

View file

@ -10,6 +10,7 @@ import (
"github.com/smallstep/certificates/acme"
"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.
@ -18,6 +19,9 @@ func WriteError(w http.ResponseWriter, err error) {
case *acme.Error:
w.Header().Set("Content-Type", "application/problem+json")
err = k.ToACME()
case *scep.Error:
// TODO: check if this is correct; and should we do some more processing?
w.Header().Set("Content-Type", "text/plain")
default:
w.Header().Set("Content-Type", "application/json")
}