2021-10-30 07:52:50 +00:00
|
|
|
package api
|
|
|
|
|
2021-11-02 05:26:07 +00:00
|
|
|
import (
|
|
|
|
"encoding/pem"
|
|
|
|
"net/http"
|
|
|
|
)
|
2021-10-30 07:52:50 +00:00
|
|
|
|
2021-11-02 05:26:07 +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) {
|
2021-11-02 05:26:07 +00:00
|
|
|
crlBytes, err := h.Authority.GenerateCertificateRevocationList(false)
|
2021-10-30 07:52:50 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
w.WriteHeader(500)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-11-02 05:26:07 +00:00
|
|
|
pemBytes := pem.EncodeToMemory(&pem.Block{
|
|
|
|
Type: "X509 CRL",
|
|
|
|
Bytes: crlBytes,
|
|
|
|
})
|
|
|
|
|
2021-10-30 07:52:50 +00:00
|
|
|
w.WriteHeader(200)
|
2021-11-02 05:26:07 +00:00
|
|
|
_, err = w.Write(pemBytes)
|
2021-10-30 07:52:50 +00:00
|
|
|
}
|