test

package
v0.0.0-...-116ca14 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CertTemplate

func CertTemplate(signAlgo x509.SignatureAlgorithm) (*x509.Certificate, error)

Suported SignatureAlgorithm: x509.SHA256WithRSA, SignatureAlgorithm: x509.ECDSAWithSHA256,

func ClientTLSCRT

func ClientTLSCRT(rootCert *x509.Certificate, rootKey interface{}, clientCertTmpl *x509.Certificate) (*tls.Certificate, []byte, interface{}, error)

Optional cert template

func CreateCert

func CreateCert(template, parent *x509.Certificate, pub interface{}, parentPriv interface{}) (
	cert *x509.Certificate, certPEM []byte, err error)

func NewTLSCommunication

func NewTLSCommunication(handler http.Handler) (TestTLSServer, TestTLSClient, error)

defer ts.Close() on succeess

func NewTestTLSClient

func NewTestTLSClient(certPool *x509.CertPool, clientTLSCert *tls.Certificate) *http.Client

func NewUnstartedTestTLSServer

func NewUnstartedTestTLSServer(certPool *x509.CertPool, servTLSCert *tls.Certificate, handler http.Handler) *httptest.Server

return a tls httptest.NewUnstartedServer defer ts.Close()

func RootTLSCRT

func RootTLSCRT(rootCertTmpl *x509.Certificate) (*x509.Certificate, []byte, interface{}, error)

Optional cert template returns rootCRT: to generate the client crt RootCRTPEM: to generate the trusted cert pool Rootkey: to generate the client crt error

func ServerTLSCRT

func ServerTLSCRT(rootCert *x509.Certificate, rootKey interface{}, servCertTmpl *x509.Certificate) (*tls.Certificate, []byte, interface{}, error)

Optional cert template

Types

type TestTLSClient

type TestTLSClient struct {
	Client  *http.Client
	Crt     *tls.Certificate
	PrivKey interface{}
	Subject pkix.Name
}

type TestTLSServer

type TestTLSServer struct {
	Server  *httptest.Server
	Crt     *tls.Certificate
	PrivKey interface{}
	Subject pkix.Name
}

Jump to

Keyboard shortcuts

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