add proper content type to force the browser to download the files instead of rendering their content

This commit is contained in:
m5r 2023-12-12 23:33:14 +01:00
parent c639bddaeb
commit 5b6c21ef6d
No known key found for this signature in database
GPG Key ID: 5BC847276DD5DDEA

View File

@ -1,15 +1,19 @@
package http
import (
"log"
"net/http"
)
func ServeCertificate() {
http.HandleFunc("/server.key", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/octet-stream")
http.ServeFile(w, r, "/certs/server.key")
})
http.HandleFunc("/server.pem", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/x-x509-ca-cert")
http.ServeFile(w, r, "/certs/server.pem")
})
log.Printf("Serving cert files on :9229\n")
http.ListenAndServe(":9229", nil)
}