mytls

package
v0.0.0-...-1953d15 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCertificate

func GenerateCertificate(duration time.Duration, certFile, keyFile string) error

GenerateCertificate generates an unsigned certificate with a random key pair.

If duration <= 0, then duration is assigned 365 days.

func SignCertificate

func SignCertificate(certFile, parentCertFile, parentKeyFile string) error

SignCertificate uses a parent certificate to sign the given certificate.

To self-sign a certificate pass parentCertFile == "". The behavior is undefined if certFile and parentCertFile point to the same file in the file system.

func UpgradeListener

func UpgradeListener(l net.Listener, u *ConnUpgrader) net.Listener

UpgradeListener upgrades a net.Listener for Accept()ing secure connections.

Types

type ConnUpgrader

type ConnUpgrader struct {
	// contains filtered or unexported fields
}

ConnUpgrader provides an interface for upgrading insecure connections into secure ones.

func NewConnUpgrader

func NewConnUpgrader(
	trustedCertFiles []string,
	certFile, keyFile string,
	handshakeReadTimeout time.Duration,
) (*ConnUpgrader, error)

NewConnUpgrader loads the trusted root certificates for authenticating peers and a (cert, key) pair of files for self-authentication and returns a factory for upgrading insecure connections into secure ones.

If an empty set of trusted root certificates is passed, any certificate chain with all signatures valid will be trusted.

If handshakeReadTimeout <= 0, then reading handshake messages will not timeout.

func (*ConnUpgrader) Upgrade

func (u *ConnUpgrader) Upgrade(c net.Conn, remoteAddr string) net.Conn

Upgrade upgrades a connection by performing the handshake.

Jump to

Keyboard shortcuts

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