Metadata-Version: 2.4
Name: cert2temp
Version: 0.1.0
Summary: SSL Certificate Temporary Folder Management Utility
Home-page: https://github.com/minicom365/cert2temp
Author: Minicom
Author-email: Minicom <3387910@naver.com>
Maintainer-email: Minicom <3387910@naver.com>
License: MIT License
        
        Copyright (c) 2025 주인님의 AI 비서
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/minicom365/cert2temp
Project-URL: Documentation, https://cert2temp.readthedocs.io/
Project-URL: Repository, https://github.com/minicom365/cert2temp
Project-URL: Issues, https://github.com/minicom365/cert2temp/issues
Project-URL: Changelog, https://github.com/minicom365/cert2temp/blob/main/CHANGELOG.md
Keywords: ssl,certificate,temp,temporary,folder,path,unicode,ascii,cross-platform
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: System :: Networking
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25.0
Requires-Dist: certifi>=2020.12.5
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Provides-Extra: curl
Requires-Dist: curl-cffi>=0.6.0; extra == "curl"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# cert2temp

SSL Certificate Temporary Folder Management Utility

[![PyPI version](https://badge.fury.io/py/cert2temp.svg)](https://pypi.org/project/cert2temp/)
[![Python versions](https://img.shields.io/pypi/pyversions/cert2temp.svg)](https://pypi.org/project/cert2temp/)
[![License](https://img.shields.io/pypi/l/cert2temp.svg)](https://pypi.org/project/cert2temp/)

## 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

```bash
pip install cert2temp
```

## Usage

### Basic Usage

```python
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

```python
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

```python
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:

```python
# 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:

```python
# 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](https://github.com/minicom365/cert2temp/issues).

## Developer Information

- **Author**: Minicom
- **Email**: 3387910@naver.com
- **GitHub**: https://github.com/minicom365/cert2temp
