Skip to main content

A comprehensive Python SDK for digital certificate management and XML digital signing

Project description

ManageX XML Signing SDK

Python Version Platform

A comprehensive Python SDK for digital certificate management and XML digital signing with enterprise-grade security and multi-platform support.

๐Ÿ“‹ Latest Updates

  • โœ… Complete OCSP Implementation: Full OCSP certificate validation with real-time revocation checking
  • โœ… Enhanced Security: Comprehensive certificate chain validation and revocation checking via CRL and OCSP
  • ๐Ÿ”’ Enterprise-Grade: Production-ready security implementation for enterprise applications

๐Ÿš€ Features

  • โœ… Multi-platform Support: Windows, Linux, macOS
  • โœ… Multiple Certificate Sources: Windows Store, PFX files, HSM tokens
  • โœ… Enterprise Security: Cryptographic verification against trusted root CAs
  • โœ… XML Digital Signing: Full XML-DSig standard (RFC 3275) compliance
  • โœ… Advanced Certificate Validation: AKI/SKI matching, CRL/OCSP checking
  • โœ… Flexible Certificate Filtering: By CN, Organization, Email, Serial Number, CA
  • โœ… HSM Token Support: PKCS#11 compatible hardware security modules
  • โœ… User-Friendly: Windows certificate selection dialog integration
  • โœ… Production Ready: Comprehensive error handling and logging

๐Ÿ“ฆ Installation

1. Create and Activate Virtual Environment

Windows:

python -m venv ocsp
pdf\Scripts\activate

macOS/Linux:

python3 -m venv ocsp
source pdf/bin/activate

pip install -r requirements.txt

# SDK
managex-xml-sdk

# Core dependencies
cryptography>=3.4.8
lxml>=4.6.3
requests>=2.25.1

# Windows-specific dependencies
pywin32>=228; sys_platform == "win32"

# HSM token support (optional)
PyKCS11>=1.5.12

# Development dependencies (optional)
pytest>=6.2.5
pytest-cov>=2.12.1
black>=21.9b0
flake8>=3.9.2
mypy>=0.910

# Documentation (optional)
sphinx>=4.2.0
sphinx-rtd-theme>=1.0.0

# Build tools
setuptools>=57.4.0
wheel>=0.37.0
twine>=3.4.2

๐Ÿƒ Quick Start

Basic XML Signing with Windows Certificate Store

from managex_xml_sdk.core.xml_signer import XMLSigner

# Create signer with automatic certificate selection dialog
signer = XMLSigner.create(
    method="store",
    store="MY",
    trusted_roots_folder="root_certificates"
)

# Sign XML file - Windows dialog will appear for certificate selection
success = signer.sign_file("document.xml", "signed_document.xml")
print(f"Signing successful: {success}")

Advanced Configuration

from managex_xml_sdk import (
    XMLSigner,
    WindowsStoreConfig,
    CertificateFilter,
    ValidationConfig,
    SignatureEnvelopeParameters
)

# Configure certificate filtering
cert_filter = CertificateFilter(
    cn="Aniket Chaturvedi",           # Common Name
    o="ManageX",                      # Organization
    email="user@company.com",         # Email from SAN
    ca="Capricorn CA"                 # Issuing CA
)

# Configure validation with trusted root certificates
validation = ValidationConfig(
    check_validity=True,              # Check certificate expiration
    check_revocation_crl=True,        # Check CRL revocation
    check_revocation_ocsp=False,      # Check OCSP revocation
    trusted_roots_folder="root_certificates"  # Folder with trusted root CAs
)

# Create Windows Store configuration
config = WindowsStoreConfig(
    store="MY",
    certificate_filter=cert_filter,
    validation_config=validation
)

# Create XML signer
signer = XMLSigner(config)

# Sign with custom signature parameters
signature_params = SignatureEnvelopeParameters.create_default("ManageX-Signature")
signer.sign_file("document.xml", "signed_document.xml")

๐Ÿ”ง Command Line Usage

The SDK includes a comprehensive command-line tool compatible with existing workflows:

# Basic signing with Windows Store (shows certificate selection dialog)
python managex_xml_signing_example.py --use-store --file document.xml

# Sign with specific certificate criteria
python managex_xml_signing_example.py --cn "Aniket" --o "ManageX" --file document.xml

# HSM token signing with PIN protection
python managex_xml_signing_example.py --use-hsm --file document.xml

# PFX file signing
python managex_xml_signing_example.py --use-pfx mycert.pfx --file document.xml

# List available certificates
python managex_xml_signing_example.py --list-certs

# List HSM tokens
python managex_xml_signing_example.py --list-tokens

๐Ÿ“ Certificate Sources

1. Windows Certificate Store

config = WindowsStoreConfig(
    store="MY",  # Personal certificate store
    certificate_filter=CertificateFilter(cn="Your Name"),
    validation_config=ValidationConfig.basic_validation("root_certificates")
)

2. PFX Files (PKCS#12)

config = PFXConfig(
    pfx_file="certificate.pfx",
    password="your_password",
    certificate_filter=CertificateFilter(cn="Your Name"),
    validation_config=ValidationConfig.basic_validation("root_certificates")
)

3. HSM Tokens (PKCS#11)

config = HSMConfig(
    dll_path="C:\\Windows\\System32\\eToken.dll",  # Auto-detected if None
    pin="123456",  # Will prompt if not provided
    certificate_filter=CertificateFilter(cn="Your Name"),
    validation_config=ValidationConfig.basic_validation("root_certificates")
)

๐Ÿ” Security Features

Trusted Root Certificate Validation

Place your trusted root CA certificates in PEM format:

root_certificates/
โ”œโ”€โ”€ CCA_India/
โ”‚   โ””โ”€โ”€ CCA_India_2022.pem
โ”œโ”€โ”€ Capricorn/
โ”‚   โ”œโ”€โ”€ Capricorn_CA_2022.pem
โ”‚   โ””โ”€โ”€ Capricorn_Sub_CA_Individual_2022.pem
โ”œโ”€โ”€ eMudhra/
โ”‚   โ””โ”€โ”€ eMudhra_Root_CA.pem
โ””โ”€โ”€ Other_CAs/
    โ””โ”€โ”€ custom_ca.pem

Certificate Chain Validation

  • AKI/SKI Matching: Authority Key Identifier to Subject Key Identifier validation
  • Cryptographic Verification: Digital signature verification against root CAs
  • Key Usage Validation: Ensures certificates have proper key usage for signing
  • Revocation Checking: CRL and OCSP support

HSM Token Protection

  • PIN Retry Limits: Prevents token locking with multiple failed attempts
  • Token Status Monitoring: Checks remaining PIN attempts before proceeding
  • Graceful Abort: User can cancel operations to prevent token lock

๐Ÿ“– API Reference

Core Classes

XMLSigner

Main class for XML signing operations.

signer = XMLSigner(config, signature_params)
signer.sign_file(input_file, output_file)  # Sign file
signed_content = signer.sign_content(xml_bytes)  # Sign content

Configuration Classes

  • WindowsStoreConfig: Windows Certificate Store configuration
  • PFXConfig: PFX file configuration
  • HSMConfig: HSM token configuration

Filter and Validation

  • CertificateFilter: Certificate selection criteria
  • ValidationConfig: Certificate validation rules
  • SignatureEnvelopeParameters: XML signature customization

Utility Functions

Certificate Discovery

from managex_xml_sdk.signers.windows_store_signer import WindowsStoreSigner

signer = WindowsStoreSigner(config)
certificates = signer.get_all_certificates_from_store()
valid_certs = signer.filter_valid_signing_certificates(certificates)

HSM Token Discovery

from managex_xml_sdk.signers.hsm_signer import HSMSigner

tokens = HSMSigner.get_all_available_tokens()
for token in tokens:
    print(f"Token: {token['label']} - {token['manufacturer']}")

๐Ÿ› ๏ธ Development

Prerequisites

  • Python 3.8+
  • Windows: pywin32, PyKCS11 (for HSM support)
  • Linux/macOS: PyKCS11 (for HSM support)

๐Ÿ‘จโ€๐Ÿ’ป Author & Support

Aniket Chaturvedi

Support

๐Ÿ™ Acknowledgments

  • Thanks to all contributors and the open-source community
  • Built with โค๏ธ for the digital certificate and XML signing ecosystem
  • Special thanks to collaborators and early adopters

๐Ÿ“Š Project Status

  • โœ… Stable: Production ready
  • ๐Ÿ”„ Active Development: Regular updates and improvements
  • ๐ŸŒ Community Driven: Open to contributions and feedback

Made with โค๏ธ by Aniket Chaturvedi for ManageX

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

managex_xml_sdk-1.0.2.tar.gz (76.4 kB view details)

Uploaded Source

Built Distribution

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

managex_xml_sdk-1.0.2-py3-none-any.whl (40.2 kB view details)

Uploaded Python 3

File details

Details for the file managex_xml_sdk-1.0.2.tar.gz.

File metadata

  • Download URL: managex_xml_sdk-1.0.2.tar.gz
  • Upload date:
  • Size: 76.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for managex_xml_sdk-1.0.2.tar.gz
Algorithm Hash digest
SHA256 0fba53e346a169894ee80b1c2c509adbb5461d35b141baf6e7e4f1128afc301d
MD5 e6d20ee46188bdd4777fd7a123a7d1de
BLAKE2b-256 fb56cea7f9dd2e4d87675fe57cd625b65193e4c1504e096b5a5f04afe14e5b5f

See more details on using hashes here.

File details

Details for the file managex_xml_sdk-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for managex_xml_sdk-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 033dd6236b4f2d3cf65e8d4827f81d5e49478d36e39fcddd32236662a36eeeb5
MD5 fd6506cb55e76a0b67f43f87afca87c0
BLAKE2b-256 34c4542463b85f4e2c7bc4766b674d7b554d7d7422c7b5c455f89de3062e8f6d

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 Pingdom Monitoring Sentry Error logging StatusPage Status page