Gentls: self-signed TLS
Overview
gentls
is a small package to generate self-signed TLS for development purposes.
Example
package main
import (
"crypto/x509/pkix"
"fmt"
"github.com/AlexanderMatveev/gentls"
"log"
"net/http"
"time"
)
func main() {
server := http.Server{
Addr: fmt.Sprintf(":%d", 3443),
}
start := time.Now()
log.Print("Generating TLS certs")
var err error
if server.TLSConfig, err = gentls.New(1024, pkix.Name{
Organization: []string{"SelfSigned"},
Country: []string{"RU"},
Locality: []string{"Moscow"},
}, time.Now().AddDate(10, 0, 0)); err != nil {
log.Fatal(err)
}
log.Printf("TLS certs generated in %s", time.Since(start))
log.Fatal(server.ListenAndServeTLS("", ""))
}