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.2.2.tar.gz (481.4 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.2.2-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.2.2-cp314-cp314-manylinux_2_38_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ ARM64

python_nss_ng-1.2.2-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.2.2-cp313-cp313-manylinux_2_38_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ ARM64

python_nss_ng-1.2.2-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.2.2-cp312-cp312-manylinux_2_38_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ ARM64

python_nss_ng-1.2.2-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.2.2-cp311-cp311-manylinux_2_38_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.38+ ARM64

python_nss_ng-1.2.2-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.2.2-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.2.2.tar.gz.

File metadata

  • Download URL: python_nss_ng-1.2.2.tar.gz
  • Upload date:
  • Size: 481.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for python_nss_ng-1.2.2.tar.gz
Algorithm Hash digest
SHA256 d96eea15612a0499355ffdeb32212dfd5c2af7850d001dbe0cfec91b1884864e
MD5 60715ee1071d12b788e5eb77441d02e4
BLAKE2b-256 982bfbd5b58b0b3746b4b000d8bcea9f52d296761a3cf809ab35b6c67461c76d

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.2.2.tar.gz:

Publisher: build-test-release.yaml on lfreleng-actions/python-nss-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for python_nss_ng-1.2.2-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 f7fabefc6a1d8716390e9815e3d25aa0398f1b6be4abe4780c20bb103ad47ac8
MD5 f98a9aa3593757529507150907949e0d
BLAKE2b-256 dc14a95845eed5c05353f5ac3d74dd1b1b865827fa4996213a6be1ddc47c95ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.2.2-cp314-cp314-manylinux_2_38_x86_64.whl:

Publisher: build-test-release.yaml on lfreleng-actions/python-nss-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for python_nss_ng-1.2.2-cp314-cp314-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 ff6d21ada8dd11660a6be2135d7ab70cc206b6757e300cc7c0259d3d9a2b2191
MD5 add20525f5a6e566d90a9774e69625b1
BLAKE2b-256 4c373c0e9541f46f62f95162e10eeea0c02c5338c8c6c477b253ebf2c1e578c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.2.2-cp314-cp314-manylinux_2_38_aarch64.whl:

Publisher: build-test-release.yaml on lfreleng-actions/python-nss-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for python_nss_ng-1.2.2-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 d98fb28cd624b23269353f883c7e6c6989b0f3e0b115d1033c9c99ec1ee90bb9
MD5 913a9ac584b23b7d8cfd361268755844
BLAKE2b-256 bd0a75b3e59411899a8c7e4b979a84cff3bcd0fce8359ec8e7c57eab0caff3b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.2.2-cp313-cp313-manylinux_2_38_x86_64.whl:

Publisher: build-test-release.yaml on lfreleng-actions/python-nss-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for python_nss_ng-1.2.2-cp313-cp313-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 a6dc196b816da7b5002ee4196a8899d1088c63cf6863cf38891116b11d28b1fb
MD5 acdb84e6307aaeb7882ba7c879743ba6
BLAKE2b-256 3f4e901deded0a17d3d92d2702d8f497f3d75523c278217d003e9e4cfea8e55f

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.2.2-cp313-cp313-manylinux_2_38_aarch64.whl:

Publisher: build-test-release.yaml on lfreleng-actions/python-nss-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for python_nss_ng-1.2.2-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 af2fb1a896d0da6c5929a121cd29619886fc9a68bee1bd7a86a70bb186845018
MD5 377698a09fd6a0084b23ef581d198e23
BLAKE2b-256 bbb16fd7b6cf97fc6a81d77a07aa616eb004c23cf144da053dc30e16884ba5b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.2.2-cp312-cp312-manylinux_2_38_x86_64.whl:

Publisher: build-test-release.yaml on lfreleng-actions/python-nss-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for python_nss_ng-1.2.2-cp312-cp312-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 8fb3d1a7975e4067ac0884493cc834f449a1da4ce51f5085107f99a15f62ea7d
MD5 c5c683f28e11b84d4f10c8d648b5a6a3
BLAKE2b-256 70ed091f395b64b3fbd1955118fb19624f766ca850a2b1aa765c13bae156b2bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.2.2-cp312-cp312-manylinux_2_38_aarch64.whl:

Publisher: build-test-release.yaml on lfreleng-actions/python-nss-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for python_nss_ng-1.2.2-cp311-cp311-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 cdbc4b0427263cd81dfb3143262a3d5b6ea0c7f3b3f7408e3fcbaa23777c7bc6
MD5 4c02b75f1aa4ecde60395f9acff45c25
BLAKE2b-256 c07d0223544e6bfdda5b688db4e6f99cc4a655531ca55719b7562fdc3b05e4b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.2.2-cp311-cp311-manylinux_2_38_x86_64.whl:

Publisher: build-test-release.yaml on lfreleng-actions/python-nss-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for python_nss_ng-1.2.2-cp311-cp311-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 711618ac6db4447c18fccd46196e23e42f74cca46231a93a8c1211f5cf6b5a92
MD5 1d2bf1f9a4e0c9c3c0b764e4c33763ff
BLAKE2b-256 b0fa5b8bd65304d0d08c0c28bcd3fd09f4a448458d2e8d428b2933a36ce5a3bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.2.2-cp311-cp311-manylinux_2_38_aarch64.whl:

Publisher: build-test-release.yaml on lfreleng-actions/python-nss-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for python_nss_ng-1.2.2-cp310-cp310-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 ce31a5fbd583268935ab8524ca3a33633945830b8ca1cfcf0d079ea5863dd98e
MD5 9ee2b44a37ea9ade80ef1030066ab2c9
BLAKE2b-256 0f134b1b4f7d200a16a858e90e5726932e438968e14bd1aac0d068b70cc76018

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.2.2-cp310-cp310-manylinux_2_38_x86_64.whl:

Publisher: build-test-release.yaml on lfreleng-actions/python-nss-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for python_nss_ng-1.2.2-cp310-cp310-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 f4f0c719d262617907c3e7876adbda1b47eef36b988ef31585d026083abdb2bc
MD5 618b980d30bc67182db651850b47fca9
BLAKE2b-256 b70f2fe23db746bcad0fe73124d1b8dc7ff8db7e3820028d9abeacade822295f

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.2.2-cp310-cp310-manylinux_2_38_aarch64.whl:

Publisher: build-test-release.yaml on lfreleng-actions/python-nss-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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