Documentation ¶
Overview ¶
Get self-signed certificate. Implements tls.Config.GetCertificate to provide an easy way to start an HTTPS server with self-signed certificate.
Example (Main) ¶
Example_main demonstrates usage of gssc package.
package main import ( "crypto/tls" "github.com/mh-cbon/gssc" "net/http" "time" ) var port = ":8080" // 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("example.org"), }, } 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")) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCertificate ¶
func GetCertificate(arg interface{}) func(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)
GetCertificte returns a function which generates a self-signed Certificate and implements tls.Config.GetCertificate.
It takes a string(hosname) or a Certopts{} whith more spceific options.
It panics if arg is not a string or a Certopts{}.
Types ¶
Click to show internal directories.
Click to hide internal directories.