From 84b28a17907c7be929d07059b43b57b6a18a2959 Mon Sep 17 00:00:00 2001 From: Brandon4466 Date: Sun, 8 Jun 2025 21:00:22 -0700 Subject: [PATCH] added SSL --- bang.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bang.go b/bang.go index 8fe68a7..f7c0dfd 100644 --- a/bang.go +++ b/bang.go @@ -331,12 +331,19 @@ func withCORS(handler http.HandlerFunc) http.HandlerFunc { func main() { port := flag.Int("port", 8080, "port to listen on") + certFile := flag.String("cert", "/etc/lighttpd/ssl/cert.pem", "path to SSL certificate file") + keyFile := flag.String("key", "/etc/lighttpd/ssl/key.pem", "path to SSL key file") flag.Parse() http.HandleFunc("/users", withCORS(createUserHandler)) http.HandleFunc("/email", withCORS(receiveEmailHandler)) http.HandleFunc("/mailbox", withCORS(listMailboxHandler)) http.HandleFunc("/mailbox/open", withCORS(markEmailOpenedHandler)) - log.Printf("Email server running on :%d", *port) - log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)) + log.Printf("Email server running with SSL on :%d", *port) + log.Fatal(http.ListenAndServeTLS( + fmt.Sprintf(":%d", *port), + *certFile, + *keyFile, + nil, + )) }