add proper content type to force the browser to download the files instead of rendering their content
This commit is contained in:
		| @@ -1,15 +1,19 @@ | |||||||
| package http | package http | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"log" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func ServeCertificate() { | func ServeCertificate() { | ||||||
| 	http.HandleFunc("/server.key", func(w http.ResponseWriter, r *http.Request) { | 	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.ServeFile(w, r, "/certs/server.key") | ||||||
| 	}) | 	}) | ||||||
| 	http.HandleFunc("/server.pem", func(w http.ResponseWriter, r *http.Request) { | 	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") | 		http.ServeFile(w, r, "/certs/server.pem") | ||||||
| 	}) | 	}) | ||||||
|  | 	log.Printf("Serving cert files on :9229\n") | ||||||
| 	http.ListenAndServe(":9229", nil) | 	http.ListenAndServe(":9229", nil) | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 m5r
					m5r