gentls

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2022 License: MIT Imports: 10 Imported by: 0

README

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


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(bits int, dn pkix.Name, expires time.Time) (*tls.Config, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL