Implement downloading generated certificates
This commit is contained in:
parent
2ed07b446d
commit
1459c1cdf4
|
@ -39,6 +39,7 @@ func server() {
|
||||||
|
|
||||||
r.GET("/", returnIndex)
|
r.GET("/", returnIndex)
|
||||||
r.GET("/cacert", returnCacert)
|
r.GET("/cacert", returnCacert)
|
||||||
|
r.GET("/download/:domain", returnCerts)
|
||||||
r.POST("/api/upload", getDomainRequest)
|
r.POST("/api/upload", getDomainRequest)
|
||||||
|
|
||||||
fmt.Printf("Listening on port %v...\n", listenPort)
|
fmt.Printf("Listening on port %v...\n", listenPort)
|
||||||
|
@ -97,7 +98,31 @@ func getDomainRequest(c *gin.Context) {
|
||||||
c.String(http.StatusInternalServerError, e)
|
c.String(http.StatusInternalServerError, e)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.File(certDownload)
|
result := fmt.Sprintf(`
|
||||||
c.File(keyDownload)
|
<b>
|
||||||
|
<p align="center">
|
||||||
|
<a target="_blank" href="download/%v.key">Download privkey</a>
|
||||||
|
</p>
|
||||||
|
<p align="center">
|
||||||
|
<a target="_blank" href="download/%v.crt">Download cert</a>
|
||||||
|
</p>
|
||||||
|
</b>
|
||||||
|
`, DNSName, DNSName)
|
||||||
|
c.String(http.StatusOK, result)
|
||||||
|
//c.File(keyDownload)
|
||||||
|
|
||||||
|
fmt.Println(certDownload, keyDownload)
|
||||||
return
|
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")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue