Skip to content

Instantly share code, notes, and snippets.

@FiloSottile
Created April 6, 2015 03:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save FiloSottile/41f5de516e9f6a038c3d to your computer and use it in GitHub Desktop.
Save FiloSottile/41f5de516e9f6a038c3d to your computer and use it in GitHub Desktop.
A short Go program to serve arbitrary HTTPS certificates for testing
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