Skip to main content

python-nss-ng

Platform Compatibility CI/CD Pipeline Python 3.10+ License: MPL-2.0

Python bindings for Network Security Services (NSS) and Netscape Portable Runtime (NSPR).

Supported Platforms

python-nss-ng officially supports:

  • Linux (all major distributions)
  • macOS

Windows is NOT supported. Attempting to import python-nss-ng on Windows will raise a RuntimeError.

Overview

python-nss-ng is a Python binding for NSS (Network Security Services) and NSPR (Netscape Portable Runtime). NSS provides cryptography services supporting SSL, TLS, PKI, PKIX, X509, PKCS*, etc. NSS is an alternative to OpenSSL and used extensively by major software projects. NSS is FIPS-140 certified.

NSS uses NSPR because NSPR provides an abstraction of common operating system services, in the areas of networking and process management. Python also provides an abstraction of common operating system services but because NSS and NSPR have tight coupling, python-nss-ng exposes elements of NSPR.

Project Modernization (2025)

This project received modernization work to support current Python versions and build standards:

Changes Made

  • Python Support: Now supports Python 3.10, 3.11, 3.12, 3.13, and 3.14
  • Build System: Migrated from legacy distutils to modern setuptools with pyproject.toml
  • Version Management: Implemented dynamic versioning using setuptools-scm
  • Package Structure: Follows current PEP standards (PEP 517, PEP 518, PEP 621)
  • Development Tools: Added support for uv, modern testing with pytest, and code quality with ruff

NSS/NSPR Compatibility

C Extension Compatibility: The C code now compiles with NSS 3.100+ and works with NSS 3.117.

Recent Fixes:

  • Resolved typedef conflicts (RSAPublicKeyPyRSAPublicKey, etc.)
  • Fixed SPDX comment block formatting issues
  • All 32 tests pass with NSS 3.117 and NSPR 4.38

Tested Versions:

  • NSS 3.117
  • NSPR 4.38.2
  • Python 3.10, 3.11, 3.12, 3.13, 3.14

System Requirements

Required Libraries

Before building python-nss-ng, you need the C language header files and libraries for both NSPR and NSS installed. This is system and distribution specific.

Fedora/RHEL/CentOS

sudo dnf install nss-devel nspr-devel

Debian/Ubuntu

sudo apt-get install libnss3-dev libnspr4-dev

macOS (Homebrew)

brew install nss nspr

Installation

Using uv (Recommended)

# Create a virtual environment with Python 3.10+
uv venv --python 3.10

# Activate the environment
source .venv/bin/activate  # Linux/macOS
# or
.venv\Scripts\activate  # Windows

# Install in development mode
uv pip install -e ".[dev]"

Using pip

# Create a virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install in development mode
pip install -e ".[dev]"

Custom Include/Library Paths

If NSS/NSPR live in non-standard locations, set the NSS_INCLUDE_ROOTS environment variable:

export NSS_INCLUDE_ROOTS="/custom/path/include:/another/path/include"
pip install -e .

Development

Test Dependencies

The test suite requires NSS command-line tools for certificate generation:

NSS Tools: Fedora/RHEL/CentOS

sudo dnf install nss-tools

NSS Tools: Debian/Ubuntu

sudo apt-get install libnss3-tools

NSS Tools: macOS (Homebrew)

The nss package includes NSS tools:

brew install nss

Running Tests

Quick Start (Automated)

Use the comprehensive test runner script that handles all setup:

# Run all tests (handles setup, builds C extension, creates certificates)
./scripts/run-all-tests.sh

# Quick mode: pure Python tests only (no C extension build needed)
./scripts/run-all-tests.sh --quick

# Other options
./scripts/run-all-tests.sh --help

The script automatically:

  • Checks for dependencies (uv, NSS, NSPR)
  • Creates virtual environment
  • Installs test dependencies
  • Builds C extension (if needed)
  • Sets up test certificates
  • Runs tests

Manual Testing

# Install with test dependencies
uv pip install -e ".[test]"

# Run tests (recommended for reliability)
pytest test/ -n0

# Or run with parallel execution (may have occasional intermittent failures)
pytest test/

Note: Some tests have known intermittent failures with parallel execution. Tests automatically generate certificates in a pki/ directory within the test folder using certutil from nss-tools. For fully reliable results, use -n0 to disable parallel execution. See TESTING.md for details about test reliability and certificate generation.

Building

# Build source distribution and wheel
uv pip install build
python -m build

Build Performance ⚡

Builds are now 40-80% faster thanks to automatic optimizations:

  • Probe Caching: Library locations cached (27% faster)
  • Parallel Compilation: Uses all CPU cores (40% faster)
  • ccache in CI: Compilation results cached (78% faster CI)

All optimizations work automatically! For even faster local builds:

# Optional: Install ccache for 87% faster rebuilds
brew install ccache  # macOS
export CC="ccache clang"

See BUILD_OPTIMIZATION_QUICKSTART.md for details.

Code Quality

Check code style and format code:

ruff check .
ruff format .

Project Structure

python-nss-ng/
├── src/                    # C extension source files and Python package
│   ├── __init__.py        # Main package initialization
│   ├── py_nss.c           # NSS bindings
│   ├── py_ssl.c           # SSL/TLS bindings
│   ├── py_nspr_io.c       # NSPR I/O bindings
│   └── py_nspr_error.c    # NSPR error handling
├── test/                  # Test suite
├── doc/                   # Documentation
├── pyproject.toml        # Modern Python project configuration
├── meson.build           # Meson build configuration
└── MANIFEST.in           # Source distribution file inclusion rules

Documentation

More information on python-nss-ng is available on the python-nss-ng project page.

For information on NSS and NSPR, see the following:

License

This project is triple-licensed under:

  • Mozilla Public License 2.0 (MPL-2.0)
  • GNU General Public License v2 or later (GPLv2+)
  • GNU Lesser General Public License v2 or later (LGPLv2+)

See LICENSE.mpl, LICENSE.gpl, and LICENSE.lgpl files for details.

Contributing

This is a modernization effort for an existing project. Contributions to fix the NSS compatibility issues and modernize the C code are welcome!

Priority Issues

  1. Fix C code compatibility with NSS 3.100+
  2. Update API usage for modern NSS/NSPR
  3. Add comprehensive test coverage
  4. Improve documentation
  5. Add type hints to Python code

Authors and Maintainers

  • Original Author: John Dennis jdennis@redhat.com
  • Current Maintainer: Project seeking active maintainer

Support

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_nss_ng-1.3.0.tar.gz (482.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

python_nss_ng-1.3.0-cp314-cp314-manylinux_2_38_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ x86-64

python_nss_ng-1.3.0-cp314-cp314-manylinux_2_38_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ ARM64

python_nss_ng-1.3.0-cp313-cp313-manylinux_2_38_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ x86-64

python_nss_ng-1.3.0-cp313-cp313-manylinux_2_38_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ ARM64

python_nss_ng-1.3.0-cp312-cp312-manylinux_2_38_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

python_nss_ng-1.3.0-cp312-cp312-manylinux_2_38_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ ARM64

python_nss_ng-1.3.0-cp311-cp311-manylinux_2_38_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.38+ x86-64

python_nss_ng-1.3.0-cp311-cp311-manylinux_2_38_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.38+ ARM64

python_nss_ng-1.3.0-cp310-cp310-manylinux_2_38_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.38+ x86-64

python_nss_ng-1.3.0-cp310-cp310-manylinux_2_38_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.38+ ARM64

File details

Details for the file python_nss_ng-1.3.0.tar.gz.

File metadata

  • Download URL: python_nss_ng-1.3.0.tar.gz
  • Upload date:
  • Size: 482.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for python_nss_ng-1.3.0.tar.gz
Algorithm Hash digest
SHA256 2fa14d2fc9a598aa7af3f3f1040ab506ff9d19ff95d1260171f34fb0122aa015
MD5 3e5f28589fd4cccd3500c670c1c114ae
BLAKE2b-256 f209d421a1f57ead67297aa5a23a2516475d2f766f50330399658987c49cf63b

See more details on using hashes here.

File details

Details for the file python_nss_ng-1.3.0-cp314-cp314-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.3.0-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 5751ff164e1c5f014e154239251988cc078c08c027b450dad33cebfbeb6f11bb
MD5 9b0402a4dc00e369b692d1103d4e45d1
BLAKE2b-256 14bb4683f9cfc846b304f74e4b4171ed62dec7fda6e40a4eef782ed0a1f5ec82

See more details on using hashes here.

File details

Details for the file python_nss_ng-1.3.0-cp314-cp314-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.3.0-cp314-cp314-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 5fa0460b8fa49139af58266f0727ca7e95f2d0b3f594e18688650f67b2a753e7
MD5 4f6a26f99009c5816507b82541162166
BLAKE2b-256 7c3a928b142f72ab64fc919e4f9426fdff7efaec6cdbcd3210bb88382d58b2a6

See more details on using hashes here.

File details

Details for the file python_nss_ng-1.3.0-cp313-cp313-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.3.0-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 c36e9421c23c9ca88e91f2a5b83715972d9527363bccce49f6b594712e647842
MD5 f95b34b638fa6519985649c2f9d0d941
BLAKE2b-256 70a282354fb20bf3a0ff9179cf2dee334f78971281d96bebc88eb9b540ab0b2f

See more details on using hashes here.

File details

Details for the file python_nss_ng-1.3.0-cp313-cp313-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.3.0-cp313-cp313-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 704e672b282682a33c3bc89e966991b3b806fdecc97e5681c7572ca0e4197c50
MD5 97f6480c9f06d88b0ae9f7bf87dfdbe8
BLAKE2b-256 997d83b9b8946c633270b4d4f2302da675fceab52e06d6b2ceadc566ddefcfaf

See more details on using hashes here.

File details

Details for the file python_nss_ng-1.3.0-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.3.0-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 d7c1f8a7e584b791b10d2f8c6c9985872687b6bf0763affe89dc2d3fe54e1803
MD5 64d6c6f81f538c0309dcf0dc015a5ab5
BLAKE2b-256 efa6fb5c7b4a12f77ad588706ef03a00e3910d200db42ba2040be351a19d41bc

See more details on using hashes here.

File details

Details for the file python_nss_ng-1.3.0-cp312-cp312-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.3.0-cp312-cp312-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 ffb3e51a9e95bcffdf8eb53c347470eab2521c8744a13de1ffea39c207569714
MD5 33b2ed1e3b6d2d160e454ef86c4ce6ea
BLAKE2b-256 e5371d9f632b49e2680ac07f877662483a95de0175226a399070b972784c78ee

See more details on using hashes here.

File details

Details for the file python_nss_ng-1.3.0-cp311-cp311-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.3.0-cp311-cp311-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 e4ff46883333cefedfd5aa7c08371b252c4d8ee16dedaf25314198e4e9e91c90
MD5 9cbdb1a559e1dbdc7894304c9232e351
BLAKE2b-256 876fcd07221c31eaef3f66f6a38f7c2e3c434838232a27ebb9514297c4c41013

See more details on using hashes here.

File details

Details for the file python_nss_ng-1.3.0-cp311-cp311-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.3.0-cp311-cp311-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 be3c34ec50994c09f85f7212e408a3254cd04e487b93930a86d8568eeb69b5f6
MD5 e988aa18954e343ed1e9254bff697aa2
BLAKE2b-256 577cbd6d14b0572f7f04a4608c29976957a8077596ec9fc0aa1a5257c69114b2

See more details on using hashes here.

File details

Details for the file python_nss_ng-1.3.0-cp310-cp310-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.3.0-cp310-cp310-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 5bff15242968e23c1e980b648da8e27333bd5d242cfea3264747594f9c384558
MD5 16753a363688c531c1bd34ceef5aba2c
BLAKE2b-256 3961af650b8748c3252b1b7f7a8a43dc77af7fe58a36b412cd34d0fa3bf4effb

See more details on using hashes here.

File details

Details for the file python_nss_ng-1.3.0-cp310-cp310-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.3.0-cp310-cp310-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 eed4b7fe6d77654a4b9ecf6be2a7c66712565a0d2678868c27983a708b3bfc79
MD5 c6d8fff0cc79d20b401fb9b58aa0f994
BLAKE2b-256 9bb490c705b64611d0cf700ba4875a16703600daa2a510f890e7b2805d9e828e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page