Skip to main content

netproxy

Version Python versions License: MIT Docs CI

A local proxy server library in pure Python where rules decide, per destination, whether to connect with a client certificate and which one. Client certificates can live in the Windows certificate store, on a smart card or in an HSM (via sslcontext), so tools that cannot do mutual TLS reach mTLS-only services through it. Documentation: https://jose-pr.github.io/netproxy/.

Features

  • Rule routing — glob and regex host rules, ports, networks and paths pick a route per connection: tunnel directly, originate TLS with a credential, chain through an upstream proxy, or reject.
  • mTLS from any keystore — a route's credential is an ssl.SSLContext you build, or a keystore query resolved by sslcontext.
  • Three ways in — an HTTP proxy (CONNECT and plain HTTP, upgraded to HTTPS when a rule says so), local tunnel ports, and optional TLS interception with a name-constrained local CA.
  • Recording — every session as a capture Wireshark follows (plaintext for the TLS the proxy owns), a TLS key log, or your own Recorder.
  • Upstream proxies — chain through a corporate proxy chosen by proxylib (PAC, environment, system settings).

Installation

pip install netproxy
Extra Adds Needed for
cli duho the netproxy command
yaml anycfg[yaml] (PyYAML) configuration files written in YAML (#!yaml, .yaml)
capture pktcap PcapRecorder: sessions written as a pcap/pcapng capture

Quick start

A configuration file routes *.corp.example through a client certificate from the Windows store; everything else goes direct:

[server]
listen = "127.0.0.1:3128"

[credentials.work]
backend = "cng"
query = { subject = "alice" }

[[rules]]
match = "*.corp.example"
action = "tls"
credential = "work"
netproxy run -c netproxy.cfg
curl -x http://127.0.0.1:3128 http://api.corp.example/   # sent as HTTPS with alice's certificate

The same from Python:

import asyncio
from netproxy import AsyncProxyServer, Credential, Route, Router

work = Credential(backend="cng", query={"subject": "alice"})
router = Router([("*.corp.example", Route.with_tls(work))])

async def main():
    async with AsyncProxyServer(router, listen="127.0.0.1:3128") as server:
        await server.serve_forever()

asyncio.run(main())

Command line

netproxy run -c netproxy.cfg          # serve
netproxy check -c netproxy.cfg https://api.corp.example/   # which rule and route, no connection
netproxy pac -c netproxy.cfg          # PAC script for browsers
netproxy ca init -c netproxy.cfg      # local CA for intercepting https:// clients

API overview

Module Purpose
netproxy the server, routes, rules and credentials
netproxy.rules matchers: host globs, regex, ports, networks, paths
netproxy.upstream reaching destinations directly or through upstream proxies
netproxy.intercept TLS interception with a name-constrained local CA
netproxy.recording recorders: a hook per session, a log, pcap files
netproxy.pac PAC scripts generated from the rules
netproxy.config configuration files (netproxy.cfg: TOML, or the format a #! first line names)
netproxy.exceptions the package's errors

Development

dotagents pyvenv && dotagents pyvenv 3.9
.pyvenv/<tag>/Scripts/python -m pip install -e ../sslcontext -e ".[dev]"
.pyvenv/<tag>/Scripts/python -m pytest -q -rs

Releasing

This project follows Semantic Versioning and keeps a CHANGELOG.md. Pushing a tag matching v* triggers the release workflow: test gate → build (checking the tag names the version built) → a strict docs build as a gate → GitHub release → publish. The release workflow never deploys the docs site itself: for a final release its last job dispatches the docs workflow at the tag, which owns every Pages deploy.

License

MIT — see LICENSE.

Metadata

Release files for netproxy 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netproxy 0.3.1
File Size Uploaded Provenance
netproxy-0.3.1.tar.gz 70.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for netproxy 0.3.1
File Interpreter ABI Platform
netproxy-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 126.9 kB

Release files / netproxy-0.3.1.tar.gz

Download URL netproxy-0.3.1.tar.gz
Size 70.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ee3dd430b0d2e1fc0740083a3341c07fd7eb735d43e78750848e7eceebb43bb9
BLAKE2b-256 checksum
How to use checksums
9dfcabc2f35d53519e8b1680250cf31da9b62026d9f0b216b109399e55c14523
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / netproxy-0.3.1-py3-none-any.whl

Download URL netproxy-0.3.1-py3-none-any.whl
Size 56.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4fe5c5a68e06744a7d0b5d4de0194717be2e9353c6820e657bc7822d433c6a1
BLAKE2b-256 checksum
How to use checksums
9e72cecfb1f005d69aba87c5515c899df8431ae9810f48f666f0c5a8ac2987d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for netproxy 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for netproxy-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page