Improve SCEP API logic and error handling
This commit is contained in:
parent
a6d50f2fa0
commit
2fc5a7f22e
4 changed files with 146 additions and 103 deletions
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue