mitm

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package mitm provides a self-signed certificate authority used by the ingest proxy to intercept TLS connections. The CA is generated once and persisted to disk (so it only has to be trusted once); per-host leaf certificates are minted on the fly during the TLS handshake and cached.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CA

type CA struct {
	// contains filtered or unexported fields
}

CA is a self-signed certificate authority. Use LoadOrCreateCA to obtain one, then TLSConfigForHost to terminate a client TLS connection while impersonating the requested host.

func LoadOrCreateCA

func LoadOrCreateCA(dir string) (*CA, error)

LoadOrCreateCA loads the CA from dir, generating and persisting a fresh one when it does not yet exist. The directory is created with 0700 perms; the CA private key is written 0600.

func (*CA) CertPath

func (c *CA) CertPath() string

CertPath returns the on-disk path of the PEM-encoded CA certificate. Clients trust this file (curl --cacert, OS/browser trust store) to verify the intercepted TLS connection.

func (*CA) ExportCert

func (c *CA) ExportCert(dst string) error

ExportCert copies the CA certificate PEM to dst (0644).

func (*CA) LeafFor

func (c *CA) LeafFor(host string) (*tls.Certificate, error)

LeafFor returns a leaf certificate impersonating host, minting and caching it on first use.

func (*CA) TLSConfigForHost

func (c *CA) TLSConfigForHost(connectHost string) *tls.Config

TLSConfigForHost returns a tls.Config for terminating a client connection opened via CONNECT to connectHost. The leaf certificate is selected by SNI; when the client sends no SNI, connectHost is used as the fallback identity.

Jump to

Keyboard shortcuts

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