DoD and Federal PKI certificate utilities: x509 parsing, CRL caching, PKCS7 trust store management, and CAC/PIV identity extraction.
Project description
pki-federal
DoD CAC, Federal PIV, and ECA provider pack for pki-core.
What's included
- Providers —
CAC_PROVIDER,PIV_PROVIDER,ECA_PROVIDERwith OID matching, CN parsers, and trust store sources - OID registries — DoD authentication, FPKI PIV authentication, and ECA policy OIDs
- CN parsers — CAC dot-format, PIV flexible, and ECA human-readable name parsing
- Trust store fetchers — download and parse CA bundles from DISA and repo.fpki.gov
- Algorithm policy —
SP800_78_ALGORITHM_POLICYwith NIST SP 800-78-5 approved algorithms - Federal CRLConfig —
CRLConfigsubclass with federal default cache directory - Federal parse_identity — defaults to the CAC + PIV registry
Generic PKI utilities (certificate loading, chain validation, revocation checking, algorithm enforcement) are imported from pki.core.
Installation
pip install pki-federal
This installs pki-core as a dependency.
Examples
Minimal — parse identity from a Federal PKI certificate
from pki.core.certificate import load_certificate
from pki.federal.identity import parse_identity
cert = load_certificate(pem_bytes)
identity = parse_identity(cert)
print(identity.credential_type) # "CAC" or "PIV"
print(identity.primary_id) # "edipi:1234567890" or "uuid:..."
print(identity.firstname, identity.lastname)
Full — FIPS 201-3 compliant validation pipeline
A production configuration implementing PKI-AUTH (FIPS 201-3 §6.2.3.1) with chain validation, SP 800-78 algorithm enforcement, and CRL + OCSP revocation checking.
from pki.core.certificate import load_certificate
from pki.core.crl import load_ca_certs_from_pem
from pki.core.revocation import CRL, OCSP, RevocationPolicy
from pki.core.validation import CertificatePolicy, ValidationStatus, validate_certificate
from pki.federal import SP800_78_ALGORITHM_POLICY, default_registry
from pki.federal.crl import CRLConfig
from pki.federal.trust_store import build_ca_bundle
# Build or load the Federal PKI CA bundle
pem_bundle, stats = build_ca_bundle(output_path="/etc/pki/dod-fpki-bundle.pem")
ca_certs = load_ca_certs_from_pem(pem_bundle)
# Load the client certificate (e.g., from mTLS header)
cert = load_certificate(pem_bytes)
# Configure the full validation pipeline
policy = CertificatePolicy(
# Chain validation against Federal PKI trust anchors
check_chain=True,
trust_store=ca_certs,
# SP 800-78 algorithm enforcement (RSA 2048+, P-256/P-384, SHA-256+)
algorithm_policy=SP800_78_ALGORITHM_POLICY,
# Federal PKI identity extraction (CAC + PIV)
registry=default_registry(),
# Revocation — CRL first, OCSP fallback, federal defaults
# (strict=True, 20 MB max CRL, 18-hour max age per FIPS 201-3)
revocation=RevocationPolicy(
checks=(CRL, OCSP),
issuer_certs=ca_certs,
crl_config=CRLConfig(cache_dir="/var/cache/pki/crls"),
),
)
result = validate_certificate(cert, policy)
if result.status == ValidationStatus.VALID:
identity = result.identity
print(f"Authenticated: {identity.credential_type} — {identity.primary_id}")
print(f"Name: {identity.firstname} {identity.lastname}")
print(f"Chain length: {len(result.chain)}")
else:
print(f"Rejected: {result.status} — {result.error}")
if result.identity:
print(f"Certificate CN: {result.identity.cn}")
Build a CA trust bundle
from pki.federal.trust_store import build_ca_bundle
pem_bundle, stats = build_ca_bundle(output_path="/etc/ssl/dod-fpki-bundle.pem")
print(f"Loaded {stats['total']} certificates, {stats['unique']} unique")
Use with custom providers
See the pki-core README for how to combine federal providers with custom provider packs.
from pki.core.providers import ProviderRegistry
from pki.federal import CAC_PROVIDER, PIV_PROVIDER
registry = ProviderRegistry()
registry.register(CAC_PROVIDER)
registry.register(PIV_PROVIDER)
registry.register(my_custom_provider)
Stricter algorithm policy
SP800_78_ALGORITHM_POLICY matches SP 800-78-5 requirements. Override
for stricter deployments:
from pki.core.algorithms import AlgorithmPolicy
# ECC P-384 only, no RSA, SHA-384+ only
ecc_only = AlgorithmPolicy(
min_rsa_bits=0,
allowed_curves=frozenset({"secp384r1"}),
allowed_hashes=frozenset({"sha384", "sha512"}),
)
Security
FIPS 140 cryptographic module status
pki-federal does not implement cryptographic primitives. All cryptographic operations are delegated to pki-core, which uses the cryptography library (OpenSSL backend).
pki-federal is not FIPS 140 validated. FIPS 140 validation applies to the underlying OpenSSL cryptographic module, not to application libraries. To deploy in a FIPS 140 compliant environment, use an OpenSSL build with a FIPS 140 validation certificate and ensure the FIPS provider is active.
SP800_78_ALGORITHM_POLICY enforces SP 800-78-5 approved algorithms at
the application level. The federal CRLConfig enforces an 18-hour maximum
CRL age per FIPS 201-3 §2.9.1. These are application-layer controls that
complement (but do not replace) FIPS 140 module validation.
NIST SP 800-53 controls
See pki-core's SP800-53-CONTROLS.md for the full controls mapping across the pki ecosystem.
pki-federal directly implements:
- IA-2(12) — PIV credential acceptance (policy OID matching, CN parsing, identity extraction)
- IA-8 / IA-8(1) — non-organizational user authentication (ECA provider), cross-agency PIV acceptance (FPKI trust store sources)
- SC-13 —
SP800_78_ALGORITHM_POLICYenforces SP 800-78 approved algorithms - SC-17 — policy OID registries for DoD, FPKI, and ECA certificate policies
Handled by pki-core (inherited dependency): chain validation, CRL/OCSP revocation, trust store management, input validation.
Must be handled higher in the stack (by the deploying application):
- IA-2 — user account mapping (e.g., smartcard-auth maps primary_id to LLDAP)
- SC-23 — session management
- AU-2 / AU-3 — audit logging
- TLS termination and challenge-response (nginx/ALB)
SBOM
CycloneDX SBOMs are generated in CI on every pipeline run.
Security testing and static analysis
See SECURITY.md for vulnerability reporting, fuzz testing coverage, and static analysis suppressions.
License
BSD-3-Clause — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pki_federal-0.4.1.tar.gz.
File metadata
- Download URL: pki_federal-0.4.1.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ecf72387fb808c85cf90127b860b06edf14367ed6786cd7c499678f858c8e8e
|
|
| MD5 |
2e1b24c17e7414cf71cf2f950afbfb0a
|
|
| BLAKE2b-256 |
8354f63a51fefc06c5f1cad5319bc69a0b1de8cc16fd998cc07dd1c98779f3b6
|
Provenance
The following attestation bundles were made for pki_federal-0.4.1.tar.gz:
Publisher:
release.yml on mevtc/pki-federal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pki_federal-0.4.1.tar.gz -
Subject digest:
0ecf72387fb808c85cf90127b860b06edf14367ed6786cd7c499678f858c8e8e - Sigstore transparency entry: 1227817914
- Sigstore integration time:
-
Permalink:
mevtc/pki-federal@7ae9f51b6e58d2bd6a843a54d6b6f32532ba3805 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/mevtc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ae9f51b6e58d2bd6a843a54d6b6f32532ba3805 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pki_federal-0.4.1-py3-none-any.whl.
File metadata
- Download URL: pki_federal-0.4.1-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77518cf447930df98871de830b7257075299ef2d61bf9b80cda8ad71f56c2cba
|
|
| MD5 |
e58e9547e84919885021da8d538921f4
|
|
| BLAKE2b-256 |
655e477ca5b19e2506256d72e7a2a26e5e7c07f44bedf7debdf8d6fe33c3e126
|
Provenance
The following attestation bundles were made for pki_federal-0.4.1-py3-none-any.whl:
Publisher:
release.yml on mevtc/pki-federal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pki_federal-0.4.1-py3-none-any.whl -
Subject digest:
77518cf447930df98871de830b7257075299ef2d61bf9b80cda8ad71f56c2cba - Sigstore transparency entry: 1227817939
- Sigstore integration time:
-
Permalink:
mevtc/pki-federal@7ae9f51b6e58d2bd6a843a54d6b6f32532ba3805 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/mevtc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ae9f51b6e58d2bd6a843a54d6b6f32532ba3805 -
Trigger Event:
push
-
Statement type: