mitm

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package mitm implements methods for working with certificates and TLS configurations that are used for mitming connections.

Index

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) GetCA

func (c *Config) GetCA() *x509.Certificate

GetCA returns the authority cert

func (*Config) GetOrCreateCert

func (c *Config) GetOrCreateCert(hostname string) (*tls.Certificate, error)

GetOrCreateCert gets or creates a certificate for the specified hostname

func (*Config) NewTLSConfigForHost

func (c *Config) NewTLSConfigForHost(hostname string) *tls.Config

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

func (c *Config) SetOrganization(organization string)

SetOrganization sets the organization name that will be used in generated certs

func (*Config) SetValidity

func (c *Config) SetValidity(validity time.Duration)

SetValidity sets validity period for the generated certs

Jump to

Keyboard shortcuts

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