Skip to main content

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

Project description

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

Project details


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.1.0.tar.gz (568.0 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.1.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.1.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.1.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.1.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.1.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.1.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.1.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.1.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.1.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.1.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.1.0.tar.gz.

File metadata

  • Download URL: python_nss_ng-1.1.0.tar.gz
  • Upload date:
  • Size: 568.0 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.1.0.tar.gz
Algorithm Hash digest
SHA256 0b11791fb1aa89252b6b34b3bd2f42ecb473467e4e0bf528444d298ac61beca3
MD5 5a99c66dd1bd8c9a633dd34e6ffd5bc9
BLAKE2b-256 2da49aaceda00e636fa58c931e152ccfbc6d88eafb859ab2fadb017460d05078

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.1.0.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.1.0-cp314-cp314-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.1.0-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 9840bf9ae3532738650deb55fc119cac40896ba4d298a13df358219ecf19dbdb
MD5 d6a05b7acf1ed560cc895427628de30f
BLAKE2b-256 32a5c6527a5438168cb8f5685815c08143a3f0781928997cde1a901857579153

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.1.0-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.1.0-cp314-cp314-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.1.0-cp314-cp314-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 421a98ab7d4374362f87960f284168e3e4b111cf30df1b99e98cd63c1d49acd2
MD5 7737f82bb7bc3d8c3b50ce42072ddd0e
BLAKE2b-256 d90dea444db496b35e04c80010dd0231e0c83ce6bccaa73b2843fdab1c09b5a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.1.0-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.1.0-cp313-cp313-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.1.0-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 9e8a44fa733dc3d6610b70bb7e6e47e2a9d26b63765b549c14c8aa6a5363cad7
MD5 c6ffdda92da7a4aaa48dfc4f2afb659e
BLAKE2b-256 862bbd586e16de375390e6769118b777d930496f0493072e232b682dda647c5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.1.0-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.1.0-cp313-cp313-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.1.0-cp313-cp313-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 5cc01d7b2d21bc9d6313b3147e0b3ab7d76c3d3de13462a758451b7e84112660
MD5 2375047a35d0884b74a4d0b86b6b6cee
BLAKE2b-256 fb76345458dd5137f66b056c131fb73d400859a8f4d52c19a1a73135da25de4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.1.0-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.1.0-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.1.0-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 125d84827f8fe1c89a463a40e059cea1248587d0f47c82294e56c9ad05d59b38
MD5 665b777f1f04985229475f153d7abafb
BLAKE2b-256 20ccc3a33c5a1f61bed20c7c712c8ad442b053f44a7d5363c80416d7d8cce460

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.1.0-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.1.0-cp312-cp312-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.1.0-cp312-cp312-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 549068efd40b929b8718b2e66a73deedd0d8324c786fd13adbd79d6356dd9ff5
MD5 e4813a60a4bfab970b229b5331708c59
BLAKE2b-256 9aa1c0f4851bdc48b8c17eee72d40f2b267e831f4f5fb9aa146e95bfc4d9d6cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.1.0-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.1.0-cp311-cp311-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.1.0-cp311-cp311-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 135a27fa9d7f9022a9efbca1bfaa827d9ecf13e51a9496013050e7b8aa913503
MD5 b758ff04304408caa5b8d493b003aa72
BLAKE2b-256 1c7cb4bd0e5298e5d9b97e1592367a08a1336ed321165b5eb5124f9eb2feafa2

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.1.0-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.1.0-cp311-cp311-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.1.0-cp311-cp311-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 832c6c3692fff5219fc26f8c6f947cdfba68666eb3850d540621400da00ca894
MD5 c8a29ecf5bc4f891902c717a278e44ec
BLAKE2b-256 861832eef1a951e79eff4903f6fc19c4b55703c71b3d209fb5706ba08a4a2a1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.1.0-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.1.0-cp310-cp310-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.1.0-cp310-cp310-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 88ff8cf984657e04a361f343ba7fc8b4f4e22dc4f82bca2d721d7c552942c505
MD5 c74bb96d76313535b61fb21c11b26ba3
BLAKE2b-256 8d9d895fca901b764e64ba844a5488533f59bcc029aa3d2d6deb27e1a1a98753

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.1.0-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.1.0-cp310-cp310-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for python_nss_ng-1.1.0-cp310-cp310-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 fea99d60569e18216b959519a959f75d04924dd820d98e9bfdc2ea30347336e2
MD5 4a6e8d77548fab26339dd526b2f7e626
BLAKE2b-256 eeb1dd92eab38c65a07383b202c46d78a7d40aa9c714b5ae70708423c6c74833

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_nss_ng-1.1.0-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 Pingdom Monitoring Sentry Error logging StatusPage Status page