Skip to main content

cert2temp

SSL Certificate Temporary Folder Management Utility

PyPI version Python versions License

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

Metadata

Release files for cert2temp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cert2temp 0.1.0
File Size Uploaded Provenance Actions
cert2temp-0.1.0.tar.gz 10.1 kB Without provenance Details for cert2temp-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cert2temp 0.1.0
File Interpreter ABI Platform Actions
cert2temp-0.1.0-py3-none-any.whl Python 3 none any Details for cert2temp-0.1.0-py3-none-any.whl

Total release size: 18.3 kB

Release files / cert2temp-0.1.0.tar.gz

Download URL cert2temp-0.1.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
01c78171234e353547170e1cfacc9aa23af34c3a51e146ef42e4ff4c0e9c2c8f
BLAKE2b-256 checksum
How to use checksums
a7d2d7542f832710a82493b072f86518d46db3dc4de46e918f3b4d75eaac005c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / cert2temp-0.1.0-py3-none-any.whl

Download URL cert2temp-0.1.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ebfeaf88c8b83fb22d65ea64b642c55dc738ff31e1b0559a076018a17d85e3f
BLAKE2b-256 checksum
How to use checksums
c431a21b73a368b1d1e75467921f0228135b05d2228cd4e2045999d7864b602f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Security for cert2temp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page