certificates/api/crl.go

25 lines
450 B
Go
Raw Normal View History

2021-10-30 07:52:50 +00:00
package api
import (
"encoding/pem"
"net/http"
)
2021-10-30 07:52:50 +00:00
// CRL is an HTTP handler that returns the current CRL in PEM format
2021-10-30 07:52:50 +00:00
func (h *caHandler) CRL(w http.ResponseWriter, r *http.Request) {
crlBytes, err := h.Authority.GenerateCertificateRevocationList(false)
2021-10-30 07:52:50 +00:00
if err != nil {
w.WriteHeader(500)
return
}
pemBytes := pem.EncodeToMemory(&pem.Block{
Type: "X509 CRL",
Bytes: crlBytes,
})
2021-10-30 07:52:50 +00:00
w.WriteHeader(200)
_, err = w.Write(pemBytes)
2021-10-30 07:52:50 +00:00
}