From 5f9a8a9f4f5f8539be73eb521e97d5f0249f9117 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Sun, 16 Jan 2022 15:25:17 +0100 Subject: [PATCH] Create bogus certificate if none passed --- FinalCommander.go | 18 ++++++++++++------ README.md | 14 +++++++++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/FinalCommander.go b/FinalCommander.go index 9e70a9a..82f8565 100644 --- a/FinalCommander.go +++ b/FinalCommander.go @@ -378,7 +378,6 @@ func handle(w http.ResponseWriter, r *http.Request) { setCORSHeaders(w) pathElements := strings.Split(r.URL.Path, "/") if len(pathElements) < 3 { - log.Printf("1") w.WriteHeader(http.StatusBadRequest) return } @@ -452,8 +451,8 @@ func checkContentServers() { func main() { //TODO: OCSP - certificatePath := flag.String("certificate", "ssl.crt", "Path to SSL certificate file.") - keypairPath := flag.String("keypair", "ssl.key", "Path to SSL key file.") + certificatePath := flag.String("certificate", "", "Path to SSL certificate file.") + keypairPath := flag.String("keypair", "", "Path to SSL key file.") listenAddress := flag.String("listen", ":7777", "Address/port to lisent on.") @@ -523,9 +522,16 @@ func main() { if err != nil { log.Fatal(err) } - serverCertificate, err := tls.LoadX509KeyPair(*certificatePath, *keypairPath) - if err != nil { - log.Fatal(err) + + var serverCertificate tls.Certificate + + if *certificatePath != "" && *keypairPath != "" { + serverCertificate, err = tls.LoadX509KeyPair(*certificatePath, *keypairPath) + if err != nil { + log.Fatal(err) + } + } else { + serverCertificate = bogusCertificate } server := &http.Server{ diff --git a/README.md b/README.md index c7aab48..b0eaeab 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,16 @@ Content-addressable storage redirector. `$ go run .` -Build via `$ go build -o fcmm` \ No newline at end of file +Build via `$ go build -o fcmm` + +### Certbot notes +* Use pip certbot +* Edit .env to add paths to certificates + +``` +$ certbot certonly \ +--standalone \ +--key-type=ecdsa --elliptic-curve=secp256r1 \ +--domain \ +--post-hook "docker restart " +``` \ No newline at end of file