SSL Certificate Temporary Folder Management Utility
Project description
cert2temp
SSL Certificate Temporary Folder Management Utility
Problem Solved
Solves SSL certificate verification failures caused by non-ASCII characters (Korean, spaces, special characters) in certificate file paths. Automatically creates safe ASCII-only temporary folders for each platform to copy certificates.
Supported Platforms
- Windows:
C:\Temp(always ASCII) - Linux:
/tmp(already ASCII) - macOS:
/tmp(already ASCII) - Others: System default temporary directory
Installation
pip install cert2temp
Usage
Basic Usage
from cert2temp import get_safe_cert_path, cleanup_temp_cert
# Copy certificate file to safe path
safe_cert_path = get_safe_cert_path(original_cert_path)
# Use for SSL requests
import requests
response = requests.get(url, verify=safe_cert_path)
# Clean up after use
cleanup_temp_cert(safe_cert_path)
Using with requests Session
from cert2temp import get_requests_session_with_safe_cert
# Create requests session with safe certificate
session = get_requests_session_with_safe_cert()
response = session.get(url)
Using with Yahoo Finance API
import yfinance as yf
from cert2temp import get_requests_session_with_safe_cert
# Bypass Yahoo Finance 429 errors with curl_cffi session
session = get_requests_session_with_safe_cert()
ticker = yf.Ticker("AAPL", session=session)
data = ticker.history(period="1mo")
API Reference
get_safe_cert_path(cert_path=None)
Copy certificate file to temporary folder and return safe path.
Parameters:
cert_path(str, optional): Original certificate file path. Uses default certificate if None
Returns:
- Safe certificate file path (str)
cleanup_temp_cert(cert_path)
Clean up temporary certificate file.
Parameters:
cert_path(str): Temporary certificate file path
Returns:
- True if cleanup successful, False otherwise (bool)
cleanup_all_temp_certs()
Clean up all temporary certificate files.
Returns:
- Number of files cleaned up (int)
get_requests_session_with_safe_cert(cert_path=None)
Create a requests session using safe certificate path.
Parameters:
cert_path(str, optional): Original certificate file path
Returns:
- requests.Session object
get_platform_safe_temp_dir()
Returns a safe ASCII-only temporary directory path for each platform.
Returns:
- Platform-specific safe temporary directory Path object
Advanced Features
Smart Folder Cleanup
cert2temp handles temporary folder cleanup intelligently:
- Original folders: Preserved (user folders)
- Empty folders we created: Removed (automatic cleanup)
Multi-platform Support
Works with the same API on all major platforms:
# Windows uses C:\Temp
# Linux/macOS uses /tmp
safe_dir = get_platform_safe_temp_dir()
Caching Feature
Copies and reuses the same certificate file only once:
# First call: File copy
path1 = get_safe_cert_path("cert.pem")
# Second call: Return cached path
path2 = get_safe_cert_path("cert.pem")
assert path1 == path2 # True
License
MIT License
Contributing
Bug reports and feature requests are welcome at GitHub Issues.
Developer Information
- Author: Minicom
- Email: 3387910@naver.com
- GitHub: https://github.com/minicom365/cert2temp
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 cert2temp-0.1.0.tar.gz.
File metadata
- Download URL: cert2temp-0.1.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01c78171234e353547170e1cfacc9aa23af34c3a51e146ef42e4ff4c0e9c2c8f
|
|
| MD5 |
8017d3653026447aaa8bc32e5bbd93b8
|
|
| BLAKE2b-256 |
a7d2d7542f832710a82493b072f86518d46db3dc4de46e918f3b4d75eaac005c
|
File details
Details for the file cert2temp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cert2temp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 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 |
5ebfeaf88c8b83fb22d65ea64b642c55dc738ff31e1b0559a076018a17d85e3f
|
|
| MD5 |
eff121d7dc712c4167eef9adec1a7620
|
|
| BLAKE2b-256 |
c431a21b73a368b1d1e75467921f0228135b05d2228cd4e2045999d7864b602f
|