Documentation
¶
Index ¶
- type CertBuilder
- func (cb *CertBuilder) Build() tls.Certificate
- func (cb *CertBuilder) BuildCert() *x509.Certificate
- func (cb *CertBuilder) BuildParsedCert() *x509.Certificate
- func (cb *CertBuilder) WithCA(isCA bool) *CertBuilder
- func (cb *CertBuilder) WithCert(cert *x509.Certificate) *CertBuilder
- func (cb *CertBuilder) WithCommonName(cn string) *CertBuilder
- func (cb *CertBuilder) WithDNSNames(names ...string) *CertBuilder
- func (cb *CertBuilder) WithDefault() *CertBuilder
- func (cb *CertBuilder) WithExtKeyUsage(usage ...x509.ExtKeyUsage) *CertBuilder
- func (cb *CertBuilder) WithIPAddresses(ips ...net.IP) *CertBuilder
- func (cb *CertBuilder) WithIssuer(b func() pkix.Name) *CertBuilder
- func (cb *CertBuilder) WithKeyUsage(usage x509.KeyUsage) *CertBuilder
- func (cb *CertBuilder) WithMaxPathLen(maxPathLen int) *CertBuilder
- func (cb *CertBuilder) WithNotAfter(b time.Time) *CertBuilder
- func (cb *CertBuilder) WithNotBefore(b time.Time) *CertBuilder
- func (cb *CertBuilder) WithOrganization(org ...string) *CertBuilder
- func (cb *CertBuilder) WithSerialNumber(serial *big.Int) *CertBuilder
- func (cb *CertBuilder) WithSignatureAlgorithm(alg x509.SignatureAlgorithm) *CertBuilder
- func (cb *CertBuilder) WithSubject(create func() pkix.Name) *CertBuilder
- func (cb *CertBuilder) WithValidity(notBefore, notAfter time.Time) *CertBuilder
- func (cb *CertBuilder) WithValidityDuration(duration time.Duration) *CertBuilder
- type ChainResult
- type TestServer
- type TestServerOptions
- type TlsConfigBuilder
- func (tcb *TlsConfigBuilder) Build() *tls.Config
- func (tcb *TlsConfigBuilder) WithCert(build func(b *CertBuilder) tls.Certificate) *TlsConfigBuilder
- func (tcb *TlsConfigBuilder) WithCerts(certs ...tls.Certificate) *TlsConfigBuilder
- func (tcb *TlsConfigBuilder) WithMaximumTLSVersion(version uint16) *TlsConfigBuilder
- func (tcb *TlsConfigBuilder) WithMinimumTLSVersion(version uint16) *TlsConfigBuilder
- func (tcb *TlsConfigBuilder) WithNextProtos(protocols ...string) *TlsConfigBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertBuilder ¶
type CertBuilder struct {
// contains filtered or unexported fields
}
func NewCertBuilder ¶
func NewCertBuilder() *CertBuilder
func (*CertBuilder) Build ¶
func (cb *CertBuilder) Build() tls.Certificate
Build returns the built certificate.
func (*CertBuilder) BuildCert ¶
func (cb *CertBuilder) BuildCert() *x509.Certificate
func (*CertBuilder) BuildParsedCert ¶ added in v0.4.0
func (cb *CertBuilder) BuildParsedCert() *x509.Certificate
BuildParsedCert returns a parsed certificate with populated Raw bytes.
func (*CertBuilder) WithCA ¶
func (cb *CertBuilder) WithCA(isCA bool) *CertBuilder
WithCA marks this as a CA certificate
func (*CertBuilder) WithCert ¶
func (cb *CertBuilder) WithCert(cert *x509.Certificate) *CertBuilder
func (*CertBuilder) WithCommonName ¶
func (cb *CertBuilder) WithCommonName(cn string) *CertBuilder
WithCommonName sets just the common name
func (*CertBuilder) WithDNSNames ¶
func (cb *CertBuilder) WithDNSNames(names ...string) *CertBuilder
WithDNSNames sets the DNS SANs
func (*CertBuilder) WithDefault ¶
func (cb *CertBuilder) WithDefault() *CertBuilder
func (*CertBuilder) WithExtKeyUsage ¶
func (cb *CertBuilder) WithExtKeyUsage(usage ...x509.ExtKeyUsage) *CertBuilder
WithExtKeyUsage sets the extended key usage
func (*CertBuilder) WithIPAddresses ¶
func (cb *CertBuilder) WithIPAddresses(ips ...net.IP) *CertBuilder
WithIPAddresses sets the IP SANs
func (*CertBuilder) WithIssuer ¶
func (cb *CertBuilder) WithIssuer(b func() pkix.Name) *CertBuilder
func (*CertBuilder) WithKeyUsage ¶
func (cb *CertBuilder) WithKeyUsage(usage x509.KeyUsage) *CertBuilder
WithKeyUsage sets the key usage flags
func (*CertBuilder) WithMaxPathLen ¶
func (cb *CertBuilder) WithMaxPathLen(maxPathLen int) *CertBuilder
WithMaxPathLen sets the maximum path length for CA certificates
func (*CertBuilder) WithNotAfter ¶
func (cb *CertBuilder) WithNotAfter(b time.Time) *CertBuilder
func (*CertBuilder) WithNotBefore ¶
func (cb *CertBuilder) WithNotBefore(b time.Time) *CertBuilder
func (*CertBuilder) WithOrganization ¶
func (cb *CertBuilder) WithOrganization(org ...string) *CertBuilder
WithOrganization sets the organization
func (*CertBuilder) WithSerialNumber ¶
func (cb *CertBuilder) WithSerialNumber(serial *big.Int) *CertBuilder
WithSerialNumber sets the certificate serial number
func (*CertBuilder) WithSignatureAlgorithm ¶
func (cb *CertBuilder) WithSignatureAlgorithm(alg x509.SignatureAlgorithm) *CertBuilder
func (*CertBuilder) WithSubject ¶
func (cb *CertBuilder) WithSubject(create func() pkix.Name) *CertBuilder
WithSubject sets the subject using a custom function
func (*CertBuilder) WithValidity ¶
func (cb *CertBuilder) WithValidity(notBefore, notAfter time.Time) *CertBuilder
WithValidity sets NotBefore and NotAfter
func (*CertBuilder) WithValidityDuration ¶
func (cb *CertBuilder) WithValidityDuration(duration time.Duration) *CertBuilder
WithValidityDuration sets validity starting from now
type ChainResult ¶
type ChainResult struct {
Root *x509.Certificate
Intermediate *x509.Certificate
Leaf *x509.Certificate
ServerCert tls.Certificate
}
ChainResult holds the result of building a root → intermediate → leaf certificate chain.
func BuildChain ¶
func BuildChain() (*ChainResult, error)
BuildChain creates a root CA, an intermediate CA, and a leaf certificate. The root signs the intermediate, the intermediate signs the leaf. ServerCert is suitable for use with a TLS server (chain leaf + intermediate; private key is the leaf's).
func BuildChainForDNSNames ¶ added in v0.4.0
func BuildChainForDNSNames(dnsNames ...string) (*ChainResult, error)
type TestServer ¶
type TestServer struct {
// contains filtered or unexported fields
}
func NewTestServer ¶
func NewTestServer(buildTlsConfig func(b *TlsConfigBuilder) *tls.Config) (*TestServer, error)
NewTestServer creates a new TLS test server
func NewTestServerWithOptions ¶ added in v0.4.0
func NewTestServerWithOptions(buildTlsConfig func(b *TlsConfigBuilder) *tls.Config, opts *TestServerOptions) (*TestServer, error)
func (*TestServer) GetAddress ¶
func (s *TestServer) GetAddress() string
func (*TestServer) Start ¶
func (s *TestServer) Start(ready chan<- struct{}) error
Start starts the test server
type TestServerOptions ¶ added in v0.4.0
type TlsConfigBuilder ¶
type TlsConfigBuilder struct {
// contains filtered or unexported fields
}
func NewTlsConfigBuilder ¶
func NewTlsConfigBuilder() *TlsConfigBuilder
func (*TlsConfigBuilder) Build ¶
func (tcb *TlsConfigBuilder) Build() *tls.Config
func (*TlsConfigBuilder) WithCert ¶
func (tcb *TlsConfigBuilder) WithCert(build func(b *CertBuilder) tls.Certificate) *TlsConfigBuilder
func (*TlsConfigBuilder) WithCerts ¶
func (tcb *TlsConfigBuilder) WithCerts(certs ...tls.Certificate) *TlsConfigBuilder
func (*TlsConfigBuilder) WithMaximumTLSVersion ¶
func (tcb *TlsConfigBuilder) WithMaximumTLSVersion(version uint16) *TlsConfigBuilder
func (*TlsConfigBuilder) WithMinimumTLSVersion ¶
func (tcb *TlsConfigBuilder) WithMinimumTLSVersion(version uint16) *TlsConfigBuilder
func (*TlsConfigBuilder) WithNextProtos ¶ added in v0.4.0
func (tcb *TlsConfigBuilder) WithNextProtos(protocols ...string) *TlsConfigBuilder