summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se (leap communications)>2019-07-02 20:04:39 +0200
committerKali Kaneko <kali@leap.se (leap communications)>2019-07-02 20:04:39 +0200
commit159b4322aeb0d4decb584a2f55182b67c17bf6d0 (patch)
treeab82a0792ae8247556a31d6af861493ba0f7b6f3 /main.go
parent05ac08d1b0f87de02d5d6c3144673994f2e2cb4b (diff)
file handler
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/main.go b/main.go
index ffa9c5c..d52d5ac 100644
--- a/main.go
+++ b/main.go
@@ -9,6 +9,7 @@ import (
"strconv"
)
+// TODO get this from the config yaml?
const keySize = 2048
const expiryDays = 28
@@ -34,6 +35,12 @@ func doFilesSanityCheck(caCrt string, caKey string) {
}
}
+func httpFileHandler(route string, path string) {
+ http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request) {
+ http.ServeFile(w, r, path)
+ })
+}
+
func main() {
var caCrt = flag.String("caCrt", "", "path to the CA public key")
var caKey = flag.String("caKey", "", "path to the CA private key")
@@ -53,6 +60,11 @@ func main() {
ci := newCaInfo(*caCrt, *caKey)
ch := certHandler{ci}
+ // add routes here
http.HandleFunc("/1/cert", ch.certResponder)
+ httpFileHandler("/1/ca.crt", "./public/ca.crt")
+ httpFileHandler("/1/configs.json", "./public/1/configs.json")
+ httpFileHandler("/1/service.json", "./public/1/service.json")
+
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(*port), nil))
}