diff --git a/cmd/serverFunc.go b/cmd/serverFunc.go index e76a511..d5b4510 100644 --- a/cmd/serverFunc.go +++ b/cmd/serverFunc.go @@ -39,6 +39,7 @@ func server() { r.GET("/", returnIndex) r.GET("/cacert", returnCacert) + r.GET("/download/:domain", returnCerts) r.POST("/api/upload", getDomainRequest) fmt.Printf("Listening on port %v...\n", listenPort) @@ -97,7 +98,31 @@ func getDomainRequest(c *gin.Context) { c.String(http.StatusInternalServerError, e) return } - c.File(certDownload) - c.File(keyDownload) + result := fmt.Sprintf(` + +

+ Download privkey +

+

+ Download cert +

+
+ `, DNSName, DNSName) + c.String(http.StatusOK, result) + //c.File(keyDownload) + + fmt.Println(certDownload, keyDownload) return } + +func returnCerts(c *gin.Context) { + domain := c.Param("domain") + base, err := os.UserHomeDir() + if err != nil { + e := fmt.Sprintf("Error happened finding user home directory: %v\n", err) + c.String(http.StatusInternalServerError, e) + return + } + c.FileAttachment(base+"/.config/cert400/clientCertificates/"+domain, domain) + //c.File(base + "/.config/cert400/clientCertificates/" + domain + ".key") +}