Documentation ¶
Overview ¶
Package mitm provides tooling for MITMing TLS connections. It provides tooling to create CA certs and generate TLS configs that can be used to MITM a TLS connection with a provided CA certificate.
Index ¶
- Variables
- func NewAuthority(name, organization string, validity time.Duration) (*x509.Certificate, *rsa.PrivateKey, error)
- type Cache
- type CacheConfig
- type CacheMetrics
- type Config
- func (c *Config) CACert() *x509.Certificate
- func (c *Config) CacheMetrics() CacheMetrics
- func (c *Config) H2Config() *h2.Config
- func (c *Config) HandshakeErrorCallback(r *http.Request, err error)
- func (c *Config) SetH2Config(h2Config *h2.Config)
- func (c *Config) SetHandshakeErrorCallback(cb func(*http.Request, error))
- func (c *Config) SetOrganization(org string)
- func (c *Config) SetValidity(validity time.Duration)
- func (c *Config) TLS(ctx context.Context) *tls.Config
- func (c *Config) TLSForHost(ctx context.Context, hostname string) *tls.Config
Constants ¶
This section is empty.
Variables ¶
MaxSerialNumber is the upper boundary that is used to create unique serial numbers for the certificate. This can be any unsigned integer up to 20 bytes (2^(8*20)-1).
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.
Types ¶
type Cache ¶ added in v1.4.0
type Cache struct { *freelru.ShardedLRU[string, *tls.Certificate] }
func NewCache ¶ added in v1.4.0
func NewCache(cfg CacheConfig) (Cache, error)
type CacheConfig ¶ added in v1.4.0
func DefaultCacheConfig ¶ added in v1.4.0
func DefaultCacheConfig() CacheConfig
type CacheMetrics ¶ added in v1.4.0
type CacheMetrics freelru.Metrics
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 any) (*Config, error)
NewConfig creates a MITM config using the CA certificate and private key to generate on-the-fly certificates.
func NewConfigWithCache ¶ added in v1.4.0
func (*Config) CACert ¶ added in v1.1.0
func (c *Config) CACert() *x509.Certificate
CACert returns the CA certificate used to sign the on-the-fly certificates.
func (*Config) CacheMetrics ¶ added in v1.4.0
func (c *Config) CacheMetrics() CacheMetrics
CacheMetrics return the metrics for the certificate cache.
func (*Config) HandshakeErrorCallback ¶
HandshakeErrorCallback calls the handshakeErrorCallback function in this Config, if it is non-nil. Request is the connect request that this handshake is being executed through.
func (*Config) SetH2Config ¶
SetH2Config configures processing of HTTP/2 streams.
func (*Config) SetHandshakeErrorCallback ¶
SetHandshakeErrorCallback sets the handshakeErrorCallback function.
func (*Config) SetOrganization ¶
SetOrganization sets the organization of the certificate.
func (*Config) SetValidity ¶
SetValidity sets the validity window around the current time that the certificate is valid for.