mitm

package
v0.0.0-...-6ebb1da Latest Latest
Warning

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

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

Documentation

Overview

Package mitm provides an in-process TLS certificate authority for HTTPS interception (man-in-the-middle). It issues and caches leaf certificates on demand, signed by a configurable root CA.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveCA

func SaveCA(ca *Authority, certFile, keyFile string) error

SaveCA writes the CA certificate and key to PEM files. The certificate is written world-readable (0644) — it's public material — and the private key is written owner-read-only (0600). If either file already existed with looser permissions, os.OpenFile with O_CREATE leaves the existing mode alone, so we explicitly Chmod the key file at the end.

Types

type Authority

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

Authority holds the proxy's root CA and issues leaf certificates on demand for each HTTPS host.

func New

func New(certFile, keyFile string) (*Authority, error)

New loads (or generates) a root CA from the given PEM files. If both paths are empty a temporary in-memory CA is generated — clients will see TLS errors unless they install the printed certificate.

func (*Authority) CACertPEM

func (a *Authority) CACertPEM() []byte

CACertPEM returns the root CA certificate in PEM format so it can be printed to stdout for the user to import into their trust store.

func (*Authority) CertFor

func (a *Authority) CertFor(host string) (*tls.Certificate, error)

CertFor returns a *tls.Certificate for the given hostname, generating and caching one signed by the root CA if needed.

Jump to

Keyboard shortcuts

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