|
|
@@ -21,6 +21,7 @@ import (
|
|
|
"github.com/go-chi/chi"
|
|
|
"github.com/pkg/errors"
|
|
|
|
|
|
+ "github.com/smallstep/certificates/api/render"
|
|
|
"github.com/smallstep/certificates/authority"
|
|
|
"github.com/smallstep/certificates/authority/config"
|
|
|
"github.com/smallstep/certificates/authority/provisioner"
|
|
|
@@ -282,7 +283,7 @@ func (h *caHandler) Route(r Router) {
|
|
|
// Version is an HTTP handler that returns the version of the server.
|
|
|
func (h *caHandler) Version(w http.ResponseWriter, r *http.Request) {
|
|
|
v := h.Authority.Version()
|
|
|
- JSON(w, VersionResponse{
|
|
|
+ render.JSON(w, VersionResponse{
|
|
|
Version: v.Version,
|
|
|
RequireClientAuthentication: v.RequireClientAuthentication,
|
|
|
})
|
|
|
@@ -290,7 +291,7 @@ func (h *caHandler) Version(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
// Health is an HTTP handler that returns the status of the server.
|
|
|
func (h *caHandler) Health(w http.ResponseWriter, r *http.Request) {
|
|
|
- JSON(w, HealthResponse{Status: "ok"})
|
|
|
+ render.JSON(w, HealthResponse{Status: "ok"})
|
|
|
}
|
|
|
|
|
|
// Root is an HTTP handler that using the SHA256 from the URL, returns the root
|
|
|
@@ -305,7 +306,7 @@ func (h *caHandler) Root(w http.ResponseWriter, r *http.Request) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- JSON(w, &RootResponse{RootPEM: Certificate{cert}})
|
|
|
+ render.JSON(w, &RootResponse{RootPEM: Certificate{cert}})
|
|
|
}
|
|
|
|
|
|
func certChainToPEM(certChain []*x509.Certificate) []Certificate {
|
|
|
@@ -329,7 +330,7 @@ func (h *caHandler) Provisioners(w http.ResponseWriter, r *http.Request) {
|
|
|
WriteError(w, errs.InternalServerErr(err))
|
|
|
return
|
|
|
}
|
|
|
- JSON(w, &ProvisionersResponse{
|
|
|
+ render.JSON(w, &ProvisionersResponse{
|
|
|
Provisioners: p,
|
|
|
NextCursor: next,
|
|
|
})
|
|
|
@@ -343,7 +344,7 @@ func (h *caHandler) ProvisionerKey(w http.ResponseWriter, r *http.Request) {
|
|
|
WriteError(w, errs.NotFoundErr(err))
|
|
|
return
|
|
|
}
|
|
|
- JSON(w, &ProvisionerKeyResponse{key})
|
|
|
+ render.JSON(w, &ProvisionerKeyResponse{key})
|
|
|
}
|
|
|
|
|
|
// Roots returns all the root certificates for the CA.
|
|
|
@@ -359,7 +360,7 @@ func (h *caHandler) Roots(w http.ResponseWriter, r *http.Request) {
|
|
|
certs[i] = Certificate{roots[i]}
|
|
|
}
|
|
|
|
|
|
- JSONStatus(w, &RootsResponse{
|
|
|
+ render.JSONStatus(w, &RootsResponse{
|
|
|
Certificates: certs,
|
|
|
}, http.StatusCreated)
|
|
|
}
|
|
|
@@ -377,7 +378,7 @@ func (h *caHandler) Federation(w http.ResponseWriter, r *http.Request) {
|
|
|
certs[i] = Certificate{federated[i]}
|
|
|
}
|
|
|
|
|
|
- JSONStatus(w, &FederationResponse{
|
|
|
+ render.JSONStatus(w, &FederationResponse{
|
|
|
Certificates: certs,
|
|
|
}, http.StatusCreated)
|
|
|
}
|