Client library for SSL Auto-Renewal Service - Monitor and auto-update SSL certificates
Project description
SSL Renewal Client Library
A lightweight Python library designed to integrate with the SSL Auto-Renewal Service API.
This library allows any Python application to:
- Automatically monitor SSL certificates
- Validate their status against a central service
- Download and update certificates automatically if they have been renewed
Installation
pip install ssl-renewal-client
Quick Start
1. Automatic Monitoring (Recommended)
The easiest way is to start the monitor in the background when your application starts.
from ssl_renewal_client import SSLMonitor
import os
def reload_web_server():
"""
Callback that executes when certificates are updated.
Here you can restart your web server (Nginx, Gunicorn, etc).
"""
print("Certificates updated! Reloading server...")
# Example: os.system("systemctl reload nginx")
# Configuration
monitor = SSLMonitor(
api_url="http://your-ssl-api.com",
domains=["yourdomain.com"],
cert_dir="/etc/letsencrypt/live", # Where to save certificates
check_interval_hours=12,
on_update_callback=reload_web_server
)
# Start in background (doesn't block your app)
monitor.start(block=False)
# ... Your application continues running here ...
2. Manual Usage (API Client)
If you prefer full control over when to check:
from ssl_renewal_client import SSLAPIClient, CertificateManager
client = SSLAPIClient("http://your-ssl-api.com")
manager = CertificateManager("/etc/letsencrypt/live")
domain = "yourdomain.com"
# 1. Validate and renew if necessary
result = client.validate_certificate(domain, auto_renew=True)
if result.get("action") == "renewed":
# 2. Download files
files_data = client.get_certificate_files(domain)
# 3. Save to disk
manager.update_certificates(domain, files_data["files"])
print("Certificates renewed and downloaded.")
else:
print("Certificate valid, no action required.")
Generated File Structure
The library will save certificates in the specified directory (cert_dir) with the following structure:
/etc/letsencrypt/live/
└── yourdomain.com/
├── fullchain.pem
├── privkey.pem
├── cert.pem
└── chain.pem
Requirements
- Python 3.7+
requests>=2.25.0
Features
- ✅ Automatic certificate monitoring
- ✅ Background thread execution (non-blocking)
- ✅ Automatic certificate download on renewal
- ✅ Callback support for service reload
- ✅ Lightweight and easy to integrate
- ✅ Thread-safe operations
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
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 ssl_renewal_client-0.1.0.tar.gz.
File metadata
- Download URL: ssl_renewal_client-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
764eca121cee808bb831955c5fba0d16334fd0510bd5307c35f5ee93a589bcb9
|
|
| MD5 |
2c3a5b521dbb408566666962e29de3e9
|
|
| BLAKE2b-256 |
da300854ad2086e635bf076111189d7c3268dd1236f5294ba9297590e55870b2
|
File details
Details for the file ssl_renewal_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ssl_renewal_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c08ce721eeac258356a01f8d00e93303ce2bb81b2f263838dec07d3fd4c8c5e
|
|
| MD5 |
a333d38b2d6772363fb413505d098b35
|
|
| BLAKE2b-256 |
bc0263fab482965a50cd8981113685d87a7ec91abededbb2793c3a099d370918
|