Documentation ¶
Index ¶
- Constants
- Variables
- func LoadOrCreateCA(caKeyFile, caCertFile string) (*x509.Certificate, *rsa.PrivateKey, error)
- func NewCA(name, organization string, validity time.Duration) (*x509.Certificate, *rsa.PrivateKey, error)
- type CertConfig
- type ConnNotify
- type OnceAcceptListener
- type Proxy
- type RequestModifyFunc
- type RequestModifyMiddleware
- type ResponseModifyFunc
- type ResponseModifyMiddleware
Constants ¶
const ReqLogIDKey contextKey = 0
Variables ¶
var ErrAlreadyAccepted = errors.New("listener already accepted")
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 LoadOrCreateCA ¶
func LoadOrCreateCA(caKeyFile, caCertFile string) (*x509.Certificate, *rsa.PrivateKey, error)
LoadOrCreateCA loads an existing CA key pair from disk, or creates a new keypair and saves to disk if certificate or key files don't exist.
func NewCA ¶
func NewCA(name, organization string, validity time.Duration) (*x509.Certificate, *rsa.PrivateKey, error)
NewCA creates a new CA certificate and associated private key.
Types ¶
type CertConfig ¶
type CertConfig struct {
// contains filtered or unexported fields
}
CertConfig is a set of configuration values that are used to build TLS configs capable of MITM.
func NewCertConfig ¶
func NewCertConfig(ca *x509.Certificate, caPrivKey crypto.PrivateKey) (*CertConfig, error)
NewCertConfig creates a MITM config using the CA certificate and private key to generate on-the-fly certificates.
func (*CertConfig) TLSConfig ¶
func (c *CertConfig) TLSConfig() *tls.Config
TLSConfig returns a *tls.Config that will generate certificates on-the-fly using the SNI extension in the TLS ClientHello.
type ConnNotify ¶
ConnNotify embeds net.Conn and adds a channel field for notifying that the connection was closed.
func (*ConnNotify) Close ¶
func (c *ConnNotify) Close()
type OnceAcceptListener ¶
type OnceAcceptListener struct {
// contains filtered or unexported fields
}
OnceListener implements net.Listener.
Accepts a connection once and returns an error on subsequent attempts.
func (*OnceAcceptListener) Addr ¶
func (l *OnceAcceptListener) Addr() net.Addr
func (*OnceAcceptListener) Close ¶
func (l *OnceAcceptListener) Close() error
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy implements http.Handler and offers MITM behaviour for modifying HTTP requests and responses.
func NewProxy ¶
func NewProxy(ca *x509.Certificate, key crypto.PrivateKey) (*Proxy, error)
NewProxy returns a new Proxy.
func (*Proxy) UseRequestModifier ¶
func (p *Proxy) UseRequestModifier(fn ...RequestModifyMiddleware)
func (*Proxy) UseResponseModifier ¶
func (p *Proxy) UseResponseModifier(fn ...ResponseModifyMiddleware)
type RequestModifyFunc ¶
RequestModifyFunc defines a type for a function that can modify a HTTP request before it's proxied.
type RequestModifyMiddleware ¶
type RequestModifyMiddleware func(next RequestModifyFunc) RequestModifyFunc
RequestModifyMiddleware defines a type for chaining request modifier middleware.
type ResponseModifyFunc ¶
ResponseModifyFunc defines a type for a function that can modify a HTTP response before it's written back to the client.
type ResponseModifyMiddleware ¶
type ResponseModifyMiddleware func(ResponseModifyFunc) ResponseModifyFunc
ResponseModifyMiddleware defines a type for chaining response modifier middleware.