Skip to content
/ gssc Public

Easily starts an HTTPS server with self-signed certificates

License

Notifications You must be signed in to change notification settings

mh-cbon/gssc

Repository files navigation

gssc

GoDoc

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

About

Easily starts an HTTPS server with self-signed certificates

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages