caroot

package module
v0.0.0-...-553deac Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 15 Imported by: 4

README

CAROOT

Usage:

1 - Setup caroot, giving is a directory name. func will be called in case this is a 1st time caroot dir.

caroot.InitCA("caroot", func(ca string) {
	log.Printf("Initiating CA: %s", ca)
})

2 - Setup tlsConfig to create/reuse the right cert based on hostname request:

log.Printf("Using https + self signed approach")
    tlscfg := &tls.Config{
        GetCertificate: func(info *tls.ClientHelloInfo) (*tls.Certificate, error) {
            ca := caroot.GetOrGenFromRoot(info.ServerName)
            return ca, nil
        },
    }

    server := &http.Server{
        Addr:      config.Addr,
        Handler:   http.DefaultServeMux,
        TLSConfig: tlscfg,
    }
    go func() {
        err := server.ListenAndServeTLS("", "")
        if err != nil {
            log.Printf("Finishing server: %s", err.Error())
        }
    }()

Pending

Better documentation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangePEMBlockPassword

func ChangePEMBlockPassword(bspem []byte, oldpass []byte, newpass []byte) (ret []byte, err error)

Muda Senha de bloco PEM

func GenCertFilesForDomain

func GenCertFilesForDomain(d string, dir string) error

func GenCertFilesForDomainInRootDir

func GenCertFilesForDomainInRootDir(d string)

func GenCertForDomain

func GenCertForDomain(d string) (keybs []byte, certbs []byte, err error)

func GenPubPrivPair

func GenPubPrivPair() (pub []byte, priv []byte, err error)

Gera par publico e privado em formato x509 - PKCS1

func GetCATLS

func GetCATLS() tls.Certificate

func GetCertFromRoot

func GetCertFromRoot(d string) *tls.Certificate

func GetOrGenFromRoot

func GetOrGenFromRoot(d string) *tls.Certificate

func InitCA

func InitCA(rdir string, installca func(ca string)) error

func PemEncodePrivKey

func PemEncodePrivKey(bs []byte) []byte

func PemEncodePubKey

func PemEncodePubKey(bs []byte) []byte

func SetRootDir

func SetRootDir(d string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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