added /cert.cer mux to download certificate for Windows
This commit is contained in:
committed by
GitHub
parent
071090f648
commit
935ef4fc26
@@ -274,6 +274,17 @@ func caHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Write(caData)
|
w.Write(caData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// caDERHandler serves the CA certificate in DER format.
|
||||||
|
func caDERHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if caCert == nil {
|
||||||
|
http.Error(w, "CA not loaded", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// The DER-encoded certificate is available as caCert.Raw.
|
||||||
|
w.Header().Set("Content-Type", "application/x-x509-ca-cert")
|
||||||
|
w.Write(caCert.Raw)
|
||||||
|
}
|
||||||
|
|
||||||
// blockHandler serves the block page.
|
// blockHandler serves the block page.
|
||||||
func blockHandler(w http.ResponseWriter, r *http.Request) {
|
func blockHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("Serving block page for %s", r.URL.String())
|
log.Printf("Serving block page for %s", r.URL.String())
|
||||||
@@ -322,6 +333,8 @@ func main() {
|
|||||||
mux.Handle("/webroot/", http.StripPrefix("/webroot/", http.FileServer(http.Dir("webroot"))))
|
mux.Handle("/webroot/", http.StripPrefix("/webroot/", http.FileServer(http.Dir("webroot"))))
|
||||||
// All other requests show the block page.
|
// All other requests show the block page.
|
||||||
mux.HandleFunc("/", blockHandler)
|
mux.HandleFunc("/", blockHandler)
|
||||||
|
// Route to serve the CA certificate in DER format.
|
||||||
|
mux.HandleFunc("/cert.cer", caDERHandler)
|
||||||
|
|
||||||
// Create a TLS configuration with our dynamic certificate callback.
|
// Create a TLS configuration with our dynamic certificate callback.
|
||||||
tlsConfig := &tls.Config{
|
tlsConfig := &tls.Config{
|
||||||
|
|||||||
Reference in New Issue
Block a user