Skip to content

Instantly share code, notes, and snippets.

@mchirico
Created September 14, 2020 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mchirico/9573cfd0b30b3318167461a99f2b42c2 to your computer and use it in GitHub Desktop.
Save mchirico/9573cfd0b30b3318167461a99f2b42c2 to your computer and use it in GitHub Desktop.
package main
import (
"io"
"log"
"net/http"
"os"
)
func main() {
name, err := os.Hostname()
if err != nil {
panic(err)
}
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "Hello, TLS!\n")
})
log.Printf("About to listen on 8443. Go to https://%s:8443/", name)
err = http.ListenAndServeTLS(":8443", "./certs/server_certificate.pem", "./certs/server_key.pem", nil)
log.Fatal(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment