Created
April 6, 2015 03:36
-
-
Save FiloSottile/41f5de516e9f6a038c3d to your computer and use it in GitHub Desktop.
A short Go program to serve arbitrary HTTPS certificates for testing
This file contains 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 ( | |
"log" | |
"net/http" | |
"os" | |
) | |
func handler(w http.ResponseWriter, req *http.Request) { | |
w.Header().Set("Content-Type", "text/plain") | |
w.Write([]byte("42.\n")) | |
} | |
func main() { | |
http.HandleFunc("/", handler) | |
log.Printf("About to listen on 127.0.0.1:10443") | |
err := http.ListenAndServeTLS("127.0.0.1:10443", os.Args[1], os.Args[2], nil) | |
if err != nil { | |
log.Fatal(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment