cert

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSelfSignedCert

func GenerateSelfSignedCert(address string, name *pkix.Name, ipAddresses ...string) (*tls.Certificate, error)

GenerateSelfSignedCert generates a self-signed TLS cert for the domain name 'address', with a private key. Other attributes of the subject can be set in 'name' and ip addresses can be set in 'ipAddresses'

func KeyToPEM

func KeyToPEM(cert *tls.Certificate) []byte

KeyToPEM serializes the private key in 'cert' to a PEM-formatted block if it's an RSA key, or nil otherwise (all certs returned by GenerateSelfSignedCert use RSA keys)

func PublicCertToPEM

func PublicCertToPEM(cert *tls.Certificate) []byte

PublicCertToPEM serializes the public x509 cert in 'cert' to a PEM-formatted block

Types

type TestListener

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

TestListener implements the net.Listener interface, returning loggingConns

func NewTestListener

func NewTestListener() *TestListener

NewTestListener initializes and returns a new TestListener. To create a new connection that that this Listener will serve on, call Dial(). To see the logged communication over that connection's pipe, see ClientToServerLog and ServerToClientLog

func (*TestListener) Accept

func (l *TestListener) Accept() (net.Conn, error)

Accept implements the corresponding method of net.Listener for TestListener

func (*TestListener) Addr

func (l *TestListener) Addr() net.Addr

Addr implements the corresponding method of net.Listener for TestListener

func (*TestListener) ClientToServerLog

func (l *TestListener) ClientToServerLog() []byte

ClientToServerLog returns the log of client -> server communication over the first (and only) connection spawned by this listener

func (*TestListener) Close

func (l *TestListener) Close() error

Close implements the corresponding method of net.Listener for TestListener. Any blocked Accept operations will be unblocked and return errors.

func (*TestListener) Dial

Dial initializes a new connection and releases a blocked call to Accept()

func (*TestListener) ServerToClientLog

func (l *TestListener) ServerToClientLog() []byte

ServerToClientLog the log of server -> client communication over the first (and only) connection spawned by this listener

Jump to

Keyboard shortcuts

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