service-identity
Service identity verification for pyOpenSSL & cryptography.
What it is and what it does
service-identity is a certificate verification library that checks whether a cryptography or pyOpenSSL certificate is valid for a given hostname or IP address. It implements RFC 6125 fully, going beyond simple hostname matching to handle wildcards, alternative names, and other service identity verification scenarios. The package protects against man-in-the-middle attacks by ensuring certificates are actually issued for the services you're connecting to.
The library recently dropped its dependency on pyasn1 in favor of cryptography's native Rust-based ASN.1 decoder, simplifying its dependency tree. It works with modern Python versions (3.8 through 3.15) and is actively maintained. The package is particularly useful when building TLS clients or servers that need robust certificate validation beyond what basic SSL libraries provide.
Use it for:
- Verify TLS certificates in custom HTTPS clients to prevent MITM attacks
- Validate certificates in pyOpenSSL-based applications before accepting connections
- Inspect certificate service identities to debug hostname mismatch errors
- Build secure reverse proxies or load balancers that validate upstream certificates
- Implement certificate validation logic in network services
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Verifies that cryptography or pyOpenSSL certificates are valid for a specific hostname or IP address, implementing RFC 6125 hostname verification and service identity inspection.
Yes. This is a focused, well-maintained security library with no known vulnerabilities, low install friction, and permissive licensing. Install it if you're building TLS clients or servers with cryptography or pyOpenSSL and need robust hostname verification beyond basic SSL defaults. The recent removal of pyasn1 dependencies makes it lighter and more maintainable.
Install
service-identity on PyPI
pip
pip install service-identityuv
uv add service-identitypoetry
poetry add service-identityInstalling service-identity
Before you install
Low friction installation with only two runtime dependencies (attrs and cryptography). Actively maintained with recent releases; status is active and supports current Python versions from 3.8 through 3.15.
License in practice
MIT license is permissive; you can use this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install service-identity
from service_identity import cryptography as si_crypto
# Verify a certificate against a hostname
si_crypto.verify_hostname(cert, hostname)
Requires cryptography 47.0.0 or later (or pyOpenSSL 26.1.0 with cryptography 47.0.0) as the package no longer depends on pyasn1.
Verify before relying
- Exact API surface and available verification methods beyond hostname checking
- Performance characteristics when verifying large certificate batches
- Whether wildcard certificate handling covers all RFC 6125 edge cases beyond the single-label fix
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — attrs, cryptography |
| Maintenance | actively maintained — 76 days since the last release |
| First released | |
| Downloads | 16,467,631/month — #1,151 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: service_identity-26.1.0-py3-none-any.whl
Keywords: cryptography, openssl, pyopenssl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
backports.ssl_match_hostnameProvides the ssl.match_hostname() function for…
permissive · top 15,000 on PyPI
ndg-httpsclientProvides enhanced HTTPS support for Python's…
permissive · top 5,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
openssl-ocsp-responderWraps OpenSSL's command-line OCSP responder to…
permissive · top 15,000 on PyPI
pip-system-certsAutomatically configures Python to use the…
permissive · top 5,000 on PyPI
types-pyOpenSSLProvides type stubs for pyOpenSSL to enable…
permissive · top 5,000 on PyPI
hstspreloadProvides a single function to check whether a…
permissive · top 15,000 on PyPI
dkimpyImplements DKIM (DomainKeys Identified Mail)…
permissive · top 5,000 on PyPI
ocspresponderImplements an RFC 6960 compliant OCSP Responder…
permissive · top 5,000 on PyPI
srpImplements the Secure Remote Password (SRP)…
permissive · top 15,000 on PyPI