change GenerateCertificateRevocationList to return DER, store DER in db instead of PEM, nicer PEM encoding of CRL, add Mock stubs
parent
e8fdb703c9
commit
7d024cc4cb
@ -1,16 +1,24 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
|
"encoding/pem"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
// CRL is an HTTP handler that returns the current CRL
|
// CRL is an HTTP handler that returns the current CRL in PEM format
|
||||||
func (h *caHandler) CRL(w http.ResponseWriter, r *http.Request) {
|
func (h *caHandler) CRL(w http.ResponseWriter, r *http.Request) {
|
||||||
crl, err := h.Authority.GenerateCertificateRevocationList(false)
|
crlBytes, err := h.Authority.GenerateCertificateRevocationList(false)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pemBytes := pem.EncodeToMemory(&pem.Block{
|
||||||
|
Type: "X509 CRL",
|
||||||
|
Bytes: crlBytes,
|
||||||
|
})
|
||||||
|
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
_, err = w.Write([]byte(crl))
|
_, err = w.Write(pemBytes)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue