Skip to content

Instantly share code, notes, and snippets.

@dmage
Created June 22, 2017 12:05
Show Gist options
  • Select an option

  • Save dmage/8bcf7077fcbd48f3a2eb2ca1d368ac83 to your computer and use it in GitHub Desktop.

Select an option

Save dmage/8bcf7077fcbd48f3a2eb2ca1d368ac83 to your computer and use it in GitHub Desktop.
debug-sni.go
package main
import (
"flag"
"fmt"
"html"
"log"
"net/http"
)
var (
addr = flag.String("addr", ":8080", "accept connections on a network address")
certFile = flag.String("cert", "", "certificate file")
keyFile = flag.String("key", "", "private key file")
)
func main() {
flag.Parse()
if *certFile == "" {
log.Fatal("no -cert option")
}
if *keyFile == "" {
log.Fatal("no -key option")
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
log.Printf("%s - %q - %s %s %s", r.RemoteAddr, r.TLS.ServerName, r.Method, r.RequestURI, r.Proto)
fmt.Fprintf(w, "TLS Server Name: %s\n", html.EscapeString(r.TLS.ServerName))
})
log.Printf("listen on %s", *addr)
log.Fatal(http.ListenAndServeTLS(*addr, *certFile, *keyFile, nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment