modulepackage
0.0.0-20161109112457-f3f114d2a8dd
Repository: https://github.com/mh-cbon/gssc.git
Documentation: pkg.go.dev
# README
gssc
Easily starts an HTTPS server with self-signed certificates.
Install
go get github.com/mh-cbon/gssc
glide install github.com/mh-cbon/gssc
Usage
package main
import (
"net/http"
"crypto/tls"
"time"
"github.com/mh-cbon/gssc"
)
var port = ":8080"
var domain = "example.org"
// Example_main demonstrates usage of gssc package.
func main() {
s := &http.Server{
Handler: &ww{},
Addr: port,
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
TLSConfig: &tls.Config{
InsecureSkipVerify: true,
GetCertificate: gssc.GetCertificate(domain),
},
}
s.ListenAndServeTLS("", "")
}
type ww struct{}
func (s *ww) ServeHTTP(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.Write([]byte("This is an example server.\n"))
}
Credits - read more
# Functions
GetCertificte returns a function which generates a self-signed Certificate and implements tls.Config.GetCertificate.