certificate

package
v0.0.0-...-79e2c14 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JKSKeyStore

func JKSKeyStore(certKey *CertKey, password string) []byte

func JKSTrustStore

func JKSTrustStore(certKeys []*CertKey, password string) []byte

Types

type CertKey

type CertKey struct {
	Certificate *x509.Certificate
	PrivateKey  *rsa.PrivateKey
	DERBytes    []byte
}

CertKey holds a certificate struct, private key and DER encoded bytes.

func New

func New(template *x509.Certificate, signer *CertKey) *CertKey

New CertKey based on template and signed by signer, or self-signed if signer is nil.

func NewCA

func NewCA(signer *CertKey, org string) *CertKey

NewCA creates a new dummy CA cert signed by signer, or self-signed if signer is nil.

func NewCert

func NewCert(signer *CertKey, org string, addrs ...interface{}) *CertKey

NewCert creates a dummy server cert signed by signer, or self-signed if signer is nil. The addrs list can contain strings (DNS names) or net.IP addresses, if addrs is empty will use "localhost", v4 and v6 loopback

func NewClient

func NewClient(signer *CertKey, org string) *CertKey

NewServer creates a dummy client cert signed by signer, or self-signed if signer is nil.

func (*CertKey) CertificatePEM

func (ck *CertKey) CertificatePEM() []byte

func (*CertKey) Client

func (ck *CertKey) Client(clientCert *CertKey) *http.Client

Client returns a HTTP client using this cert as CA. If clientCert is not nil, client will authenticate with cert.

func (*CertKey) ClientTLSConf

func (ck *CertKey) ClientTLSConf(clientCert *CertKey) *tls.Config

ClientTLSConf returns TLS configuration for a client using this cert as a CA. If clientCert is not nil, client will authenticate with cert.

func (*CertKey) PrivateKeyPEM

func (ck *CertKey) PrivateKeyPEM() []byte

func (*CertKey) ServerTLSConf

func (ck *CertKey) ServerTLSConf(clientCA *CertKey) *tls.Config

ServerTLSConf returns TLS configuration for a server using this certificate. If clientCA is not nil, we also enable client authentication using clientCA.

func (*CertKey) StartServer

func (ck *CertKey) StartServer(handler http.Handler, clientCA *CertKey) *httptest.Server

StartServer returns a started httptest.Server using this cert. If clientCA is not nil, enable client authentication.

Jump to

Keyboard shortcuts

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