certtools

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2018 License: MIT Imports: 2 Imported by: 5

README

CertTools

GoDoc Widget

CertTools is a set of settings and tools for TLS Certificates.

It includes parsers for taking strings/config options and enabling minimum TLS versions and Cipher Suites. It also includes some decent static defaults which can be used when creating a server.

import (
    "github.com/snowzach/certtools/autocert"
    "github.com/snowzach/certtools"
)

// Generate a self-signed certificate for localhost using static string as private key data (repeatable)
// This programatically generates the same certificate every time and is only for development use
cert, err = autocert.New(autocert.InsecureStringReader("static string"))

// Build an http server using our self-signed cert and decent security ciphers and versions
server := &http.Server{
    Addr: ":8443",
    Handler: http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
        w.Header().Set("Content-Type", "text/plain")
        w.Write([]byte("This is an example server.\n"))
    }),
    TLSConfig: &tls.Config{
        Certificates: []tls.Certificate{cert},
        MinVersion:   certtools.SecureTLSMinVersion(),
        CipherSuites: certtools.SecureTLSCipherSuites(),
    },
}

CertTools can be used to programatically generate POTENTIALLY INSECURE certificates that can be used for your web server. It's horribly insecure and is designed basically for the situation where you don't want to mess with cert files, you want to use tls/https and you don't want to have the cert be different every time you load your app.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTLSCipherSuites

func ParseTLSCipherSuites(suites []string) ([]uint16, error)

This parses a list of tlsCipherSuite strings and returns a slice of tls.CypherSuite values. Blank/Default = defaultTLSCipherSuites

func ParseTLSVersion

func ParseTLSVersion(version string) (uint16, error)

This takes a string TLS version and converts it into the go tls version. A blank version will return defaultTLSMinVersion

func SecureTLSCipherSuites

func SecureTLSCipherSuites() []uint16

SecureTLSCipherSuites returns secure TLSCipherSuites=defaultTLSCipherSuites

func SecureTLSMinVersion

func SecureTLSMinVersion() uint16

SecureTLSMinVersion returns a secure TLSMinVersion=defaultTLSMinVersion

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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