Created
June 22, 2017 12:05
-
-
Save dmage/8bcf7077fcbd48f3a2eb2ca1d368ac83 to your computer and use it in GitHub Desktop.
debug-sni.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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