Skip to content

AlexanderMatveev/gentls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gentls: self-signed TLS

Workflow Go Report Card

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("", ""))
}

About

Small package to generate self-signed TLS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages