From 5b6c21ef6d33f44da8c7ba00c2712d845c6641d4 Mon Sep 17 00:00:00 2001 From: m5r Date: Tue, 12 Dec 2023 23:33:14 +0100 Subject: [PATCH] add proper content type to force the browser to download the files instead of rendering their content --- http/server.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/http/server.go b/http/server.go index 2857e65..a2cdf9f 100644 --- a/http/server.go +++ b/http/server.go @@ -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) }