Documentation ¶
Overview ¶
Package mitm implements methods for working with certificates and TLS configurations that are used for MITMing connections.
Index ¶
- func NewAuthority(name, organization string, validity time.Duration) (*x509.Certificate, *rsa.PrivateKey, error)
- type CertsCache
- type CertsStorage
- type Config
- func (c *Config) GetCA() *x509.Certificate
- func (c *Config) GetOrCreateCert(hostname string) (cert *tls.Certificate, err error)
- func (c *Config) NewTLSConfigForHost(hostname string) *tls.Config
- func (c *Config) SetOrganization(organization string)
- func (c *Config) SetValidity(validity time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAuthority ¶
func NewAuthority(name, organization string, validity time.Duration) (*x509.Certificate, *rsa.PrivateKey, error)
NewAuthority creates a new CA certificate and associated private key. name -- certificate subject name organization -- certificate organization validity -- time for which the certificate is valid
Types ¶
type CertsCache ¶
type CertsCache struct {
// contains filtered or unexported fields
}
CertsCache is a simple map-based CertsStorage implementation
func (*CertsCache) Get ¶
func (c *CertsCache) Get(key string) (*tls.Certificate, bool)
Get gets the certificate from the storage
func (*CertsCache) Set ¶
func (c *CertsCache) Set(key string, cert *tls.Certificate)
Set saves the certificate to the storage
type CertsStorage ¶
type CertsStorage interface { // Get gets the certificate from the storage Get(key string) (*tls.Certificate, bool) // Set saves the certificate to the storage Set(key string, cert *tls.Certificate) }
CertsStorage is an interface for generated tls certificates storage
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a set of configuration values that are used to build TLS configs capable of MITM.
func NewConfig ¶
func NewConfig(ca *x509.Certificate, privateKey *rsa.PrivateKey, storage CertsStorage) (*Config, error)
NewConfig creates a new MITM configuration ca -- root certificate authority to use for generating domain certs privateKey -- private key of this CA GetOrCreateCert storage -- a custom certs storage or null if you want to use the default implementation
func (*Config) GetOrCreateCert ¶
func (c *Config) GetOrCreateCert(hostname string) (cert *tls.Certificate, err error)
GetOrCreateCert gets or creates a certificate for the specified hostname
func (*Config) NewTLSConfigForHost ¶
NewTLSConfigForHost creates a *tls.Config that will generate domain certificates on-the-fly using the SNI extension (if specified) or the hostname
func (*Config) SetOrganization ¶
SetOrganization sets the organization name that will be used in generated certs
func (*Config) SetValidity ¶
SetValidity sets validity period for the generated certs