fastssl 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastssl-0.1.0/PKG-INFO +174 -0
- fastssl-0.1.0/README.md +154 -0
- fastssl-0.1.0/fastssl/__init__.py +8 -0
- fastssl-0.1.0/fastssl/client.py +191 -0
- fastssl-0.1.0/fastssl.egg-info/PKG-INFO +174 -0
- fastssl-0.1.0/fastssl.egg-info/SOURCES.txt +9 -0
- fastssl-0.1.0/fastssl.egg-info/dependency_links.txt +1 -0
- fastssl-0.1.0/fastssl.egg-info/requires.txt +1 -0
- fastssl-0.1.0/fastssl.egg-info/top_level.txt +1 -0
- fastssl-0.1.0/pyproject.toml +38 -0
- fastssl-0.1.0/setup.cfg +4 -0
fastssl-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fastssl
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: FastSSL - SSL证书管理SDK,支持申请、验证和获取SSL证书
|
|
5
|
+
Author: FastSSL Team
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yourusername/fastssl
|
|
8
|
+
Project-URL: Documentation, https://github.com/yourusername/fastssl
|
|
9
|
+
Project-URL: Repository, https://github.com/yourusername/fastssl
|
|
10
|
+
Keywords: ssl,certificate,ssl-certificate,zerossl,letsencrypt
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
16
|
+
Classifier: Topic :: Security
|
|
17
|
+
Requires-Python: >=3.14
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: requests>=2.31.0
|
|
20
|
+
|
|
21
|
+
# FastSSL
|
|
22
|
+
|
|
23
|
+
FastSSL 是一个用于管理SSL证书的Python SDK,支持申请、验证和获取SSL证书。
|
|
24
|
+
|
|
25
|
+
签发密钥获取渠道:ssl.aa1.cn/user/
|
|
26
|
+
## 安装
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install fastssl
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 快速开始
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from fastssl import FastSSLClient
|
|
36
|
+
|
|
37
|
+
# 初始化客户端
|
|
38
|
+
client = FastSSLClient(api_key="your_api_key")
|
|
39
|
+
|
|
40
|
+
# 申请SSL证书
|
|
41
|
+
result = client.create_certificate(
|
|
42
|
+
certificate_domain="example.com",
|
|
43
|
+
channel_type="zerossl", # 可选: zerossl, letsencrypt, google
|
|
44
|
+
validation_method="DNS"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# 验证域名
|
|
48
|
+
verify_result = client.verify_domain(domain="example.com")
|
|
49
|
+
|
|
50
|
+
# 获取证书信息
|
|
51
|
+
cert_info = client.get_certificate_info(domain="example.com")
|
|
52
|
+
|
|
53
|
+
# 一键申请并验证(便捷方法)
|
|
54
|
+
full_result = client.create_and_verify(
|
|
55
|
+
certificate_domain="example.com",
|
|
56
|
+
channel_type="zerossl"
|
|
57
|
+
)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## API 文档
|
|
61
|
+
|
|
62
|
+
### FastSSLClient
|
|
63
|
+
|
|
64
|
+
#### `__init__(api_key: str)`
|
|
65
|
+
|
|
66
|
+
初始化FastSSL客户端。
|
|
67
|
+
|
|
68
|
+
**参数:**
|
|
69
|
+
- `api_key`: API密钥
|
|
70
|
+
|
|
71
|
+
#### `create_certificate(certificate_domain: str, channel_type: str = "zerossl", validation_method: str = "DNS")`
|
|
72
|
+
|
|
73
|
+
申请SSL证书。
|
|
74
|
+
|
|
75
|
+
**参数:**
|
|
76
|
+
- `certificate_domain`: 需要验证的域名
|
|
77
|
+
- `channel_type`: 证书品牌,可选值: `zerossl`, `letsencrypt`, `google`
|
|
78
|
+
- `validation_method`: 验证方式,默认为 `DNS`
|
|
79
|
+
|
|
80
|
+
**返回:** 包含证书申请结果的字典
|
|
81
|
+
|
|
82
|
+
#### `verify_domain(domain: str, max_retries: int = 10, retry_interval: int = 5)`
|
|
83
|
+
|
|
84
|
+
验证域名并等待证书签发完成。如果验证成功但download_url为空,会自动重试。
|
|
85
|
+
|
|
86
|
+
**参数:**
|
|
87
|
+
- `domain`: 要验证的域名
|
|
88
|
+
- `max_retries`: 最大重试次数(当download_url为空时)
|
|
89
|
+
- `retry_interval`: 重试间隔(秒)
|
|
90
|
+
|
|
91
|
+
**返回:** 包含验证结果的字典
|
|
92
|
+
|
|
93
|
+
#### `get_certificate_info(domain: str)`
|
|
94
|
+
|
|
95
|
+
获取证书信息,自动处理证书内容中的换行符。
|
|
96
|
+
|
|
97
|
+
**参数:**
|
|
98
|
+
- `domain`: 域名
|
|
99
|
+
|
|
100
|
+
**返回:** 包含证书信息的字典
|
|
101
|
+
|
|
102
|
+
#### `create_and_verify(certificate_domain: str, channel_type: str = "zerossl", validation_method: str = "DNS", max_retries: int = 10, retry_interval: int = 5)`
|
|
103
|
+
|
|
104
|
+
一键申请并验证证书的便捷方法。
|
|
105
|
+
|
|
106
|
+
**参数:**
|
|
107
|
+
- `certificate_domain`: 需要验证的域名
|
|
108
|
+
- `channel_type`: 证书品牌
|
|
109
|
+
- `validation_method`: 验证方式
|
|
110
|
+
- `max_retries`: 验证最大重试次数
|
|
111
|
+
- `retry_interval`: 重试间隔(秒)
|
|
112
|
+
|
|
113
|
+
**返回:** 包含完整流程结果的字典
|
|
114
|
+
|
|
115
|
+
## 示例
|
|
116
|
+
|
|
117
|
+
### 基本使用
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from fastssl import FastSSLClient
|
|
121
|
+
|
|
122
|
+
client = FastSSLClient(api_key="your_api_key")
|
|
123
|
+
|
|
124
|
+
# 申请证书
|
|
125
|
+
create_result = client.create_certificate(
|
|
126
|
+
certificate_domain="example.com",
|
|
127
|
+
channel_type="zerossl"
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
if create_result.get("success"):
|
|
131
|
+
print("证书申请成功!")
|
|
132
|
+
print(f"验证信息: {create_result.get('data', {}).get('verify_info')}")
|
|
133
|
+
|
|
134
|
+
# 验证域名
|
|
135
|
+
verify_result = client.verify_domain("example.com")
|
|
136
|
+
|
|
137
|
+
if verify_result.get("success"):
|
|
138
|
+
print("证书验证成功!")
|
|
139
|
+
print(f"下载地址: {verify_result.get('data', {}).get('download_url')}")
|
|
140
|
+
|
|
141
|
+
# 获取证书信息
|
|
142
|
+
cert_info = client.get_certificate_info("example.com")
|
|
143
|
+
if cert_info.get("success"):
|
|
144
|
+
print("证书内容:")
|
|
145
|
+
print(cert_info.get("data", {}).get("crt_pem"))
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 一键申请并验证
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from fastssl import FastSSLClient
|
|
152
|
+
|
|
153
|
+
client = FastSSLClient(api_key="your_api_key")
|
|
154
|
+
|
|
155
|
+
result = client.create_and_verify(
|
|
156
|
+
certificate_domain="example.com",
|
|
157
|
+
channel_type="zerossl",
|
|
158
|
+
max_retries=15, # 最多重试15次
|
|
159
|
+
retry_interval=10 # 每次间隔10秒
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
if result.get("success"):
|
|
163
|
+
verify_data = result.get("verify_result", {}).get("data", {})
|
|
164
|
+
print(f"证书编号: {verify_data.get('certificate_no')}")
|
|
165
|
+
print(f"下载地址: {verify_data.get('download_url')}")
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 许可证
|
|
169
|
+
|
|
170
|
+
MIT License
|
|
171
|
+
|
|
172
|
+
## 支持
|
|
173
|
+
|
|
174
|
+
如有问题或建议,请提交Issue。
|
fastssl-0.1.0/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# FastSSL
|
|
2
|
+
|
|
3
|
+
FastSSL 是一个用于管理SSL证书的Python SDK,支持申请、验证和获取SSL证书。
|
|
4
|
+
|
|
5
|
+
签发密钥获取渠道:ssl.aa1.cn/user/
|
|
6
|
+
## 安装
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pip install fastssl
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 快速开始
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from fastssl import FastSSLClient
|
|
16
|
+
|
|
17
|
+
# 初始化客户端
|
|
18
|
+
client = FastSSLClient(api_key="your_api_key")
|
|
19
|
+
|
|
20
|
+
# 申请SSL证书
|
|
21
|
+
result = client.create_certificate(
|
|
22
|
+
certificate_domain="example.com",
|
|
23
|
+
channel_type="zerossl", # 可选: zerossl, letsencrypt, google
|
|
24
|
+
validation_method="DNS"
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# 验证域名
|
|
28
|
+
verify_result = client.verify_domain(domain="example.com")
|
|
29
|
+
|
|
30
|
+
# 获取证书信息
|
|
31
|
+
cert_info = client.get_certificate_info(domain="example.com")
|
|
32
|
+
|
|
33
|
+
# 一键申请并验证(便捷方法)
|
|
34
|
+
full_result = client.create_and_verify(
|
|
35
|
+
certificate_domain="example.com",
|
|
36
|
+
channel_type="zerossl"
|
|
37
|
+
)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## API 文档
|
|
41
|
+
|
|
42
|
+
### FastSSLClient
|
|
43
|
+
|
|
44
|
+
#### `__init__(api_key: str)`
|
|
45
|
+
|
|
46
|
+
初始化FastSSL客户端。
|
|
47
|
+
|
|
48
|
+
**参数:**
|
|
49
|
+
- `api_key`: API密钥
|
|
50
|
+
|
|
51
|
+
#### `create_certificate(certificate_domain: str, channel_type: str = "zerossl", validation_method: str = "DNS")`
|
|
52
|
+
|
|
53
|
+
申请SSL证书。
|
|
54
|
+
|
|
55
|
+
**参数:**
|
|
56
|
+
- `certificate_domain`: 需要验证的域名
|
|
57
|
+
- `channel_type`: 证书品牌,可选值: `zerossl`, `letsencrypt`, `google`
|
|
58
|
+
- `validation_method`: 验证方式,默认为 `DNS`
|
|
59
|
+
|
|
60
|
+
**返回:** 包含证书申请结果的字典
|
|
61
|
+
|
|
62
|
+
#### `verify_domain(domain: str, max_retries: int = 10, retry_interval: int = 5)`
|
|
63
|
+
|
|
64
|
+
验证域名并等待证书签发完成。如果验证成功但download_url为空,会自动重试。
|
|
65
|
+
|
|
66
|
+
**参数:**
|
|
67
|
+
- `domain`: 要验证的域名
|
|
68
|
+
- `max_retries`: 最大重试次数(当download_url为空时)
|
|
69
|
+
- `retry_interval`: 重试间隔(秒)
|
|
70
|
+
|
|
71
|
+
**返回:** 包含验证结果的字典
|
|
72
|
+
|
|
73
|
+
#### `get_certificate_info(domain: str)`
|
|
74
|
+
|
|
75
|
+
获取证书信息,自动处理证书内容中的换行符。
|
|
76
|
+
|
|
77
|
+
**参数:**
|
|
78
|
+
- `domain`: 域名
|
|
79
|
+
|
|
80
|
+
**返回:** 包含证书信息的字典
|
|
81
|
+
|
|
82
|
+
#### `create_and_verify(certificate_domain: str, channel_type: str = "zerossl", validation_method: str = "DNS", max_retries: int = 10, retry_interval: int = 5)`
|
|
83
|
+
|
|
84
|
+
一键申请并验证证书的便捷方法。
|
|
85
|
+
|
|
86
|
+
**参数:**
|
|
87
|
+
- `certificate_domain`: 需要验证的域名
|
|
88
|
+
- `channel_type`: 证书品牌
|
|
89
|
+
- `validation_method`: 验证方式
|
|
90
|
+
- `max_retries`: 验证最大重试次数
|
|
91
|
+
- `retry_interval`: 重试间隔(秒)
|
|
92
|
+
|
|
93
|
+
**返回:** 包含完整流程结果的字典
|
|
94
|
+
|
|
95
|
+
## 示例
|
|
96
|
+
|
|
97
|
+
### 基本使用
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from fastssl import FastSSLClient
|
|
101
|
+
|
|
102
|
+
client = FastSSLClient(api_key="your_api_key")
|
|
103
|
+
|
|
104
|
+
# 申请证书
|
|
105
|
+
create_result = client.create_certificate(
|
|
106
|
+
certificate_domain="example.com",
|
|
107
|
+
channel_type="zerossl"
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
if create_result.get("success"):
|
|
111
|
+
print("证书申请成功!")
|
|
112
|
+
print(f"验证信息: {create_result.get('data', {}).get('verify_info')}")
|
|
113
|
+
|
|
114
|
+
# 验证域名
|
|
115
|
+
verify_result = client.verify_domain("example.com")
|
|
116
|
+
|
|
117
|
+
if verify_result.get("success"):
|
|
118
|
+
print("证书验证成功!")
|
|
119
|
+
print(f"下载地址: {verify_result.get('data', {}).get('download_url')}")
|
|
120
|
+
|
|
121
|
+
# 获取证书信息
|
|
122
|
+
cert_info = client.get_certificate_info("example.com")
|
|
123
|
+
if cert_info.get("success"):
|
|
124
|
+
print("证书内容:")
|
|
125
|
+
print(cert_info.get("data", {}).get("crt_pem"))
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 一键申请并验证
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from fastssl import FastSSLClient
|
|
132
|
+
|
|
133
|
+
client = FastSSLClient(api_key="your_api_key")
|
|
134
|
+
|
|
135
|
+
result = client.create_and_verify(
|
|
136
|
+
certificate_domain="example.com",
|
|
137
|
+
channel_type="zerossl",
|
|
138
|
+
max_retries=15, # 最多重试15次
|
|
139
|
+
retry_interval=10 # 每次间隔10秒
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
if result.get("success"):
|
|
143
|
+
verify_data = result.get("verify_result", {}).get("data", {})
|
|
144
|
+
print(f"证书编号: {verify_data.get('certificate_no')}")
|
|
145
|
+
print(f"下载地址: {verify_data.get('download_url')}")
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## 许可证
|
|
149
|
+
|
|
150
|
+
MIT License
|
|
151
|
+
|
|
152
|
+
## 支持
|
|
153
|
+
|
|
154
|
+
如有问题或建议,请提交Issue。
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FastSSL客户端 - 用于与SSL证书API交互
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import requests
|
|
6
|
+
import time
|
|
7
|
+
from typing import Dict, Optional, Literal
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class FastSSLClient:
|
|
11
|
+
"""FastSSL客户端类,用于管理SSL证书的申请、验证和获取"""
|
|
12
|
+
|
|
13
|
+
BASE_URL = "https://ssl.aa1.cn/api/v1"
|
|
14
|
+
|
|
15
|
+
def __init__(self, api_key: str):
|
|
16
|
+
"""
|
|
17
|
+
初始化FastSSL客户端
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
api_key: API密钥
|
|
21
|
+
"""
|
|
22
|
+
self.api_key = api_key
|
|
23
|
+
self.session = requests.Session()
|
|
24
|
+
|
|
25
|
+
def create_certificate(
|
|
26
|
+
self,
|
|
27
|
+
certificate_domain: str,
|
|
28
|
+
channel_type: Literal["zerossl", "letsencrypt", "google"] = "zerossl",
|
|
29
|
+
validation_method: str = "DNS"
|
|
30
|
+
) -> Dict:
|
|
31
|
+
"""
|
|
32
|
+
申请SSL证书
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
certificate_domain: 需要验证的域名
|
|
36
|
+
channel_type: 证书品牌,可选值: zerossl, letsencrypt, google
|
|
37
|
+
validation_method: 验证方式,默认为DNS
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
包含证书申请结果的字典
|
|
41
|
+
"""
|
|
42
|
+
url = f"{self.BASE_URL}/create"
|
|
43
|
+
|
|
44
|
+
params = {
|
|
45
|
+
"api_key": self.api_key
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
data = {
|
|
49
|
+
"channel_type": channel_type,
|
|
50
|
+
"certificate_domain": certificate_domain,
|
|
51
|
+
"validation_method": validation_method
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
# 使用 multipart/form-data 格式
|
|
56
|
+
# 传入空的 files 参数以强制使用 multipart/form-data
|
|
57
|
+
response = self.session.post(url, params=params, data=data, files={})
|
|
58
|
+
response.raise_for_status()
|
|
59
|
+
return response.json()
|
|
60
|
+
except requests.exceptions.RequestException as e:
|
|
61
|
+
return {
|
|
62
|
+
"success": False,
|
|
63
|
+
"message": f"请求失败: {str(e)}",
|
|
64
|
+
"error": str(e)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
def verify_domain(
|
|
68
|
+
self,
|
|
69
|
+
domain: str,
|
|
70
|
+
max_retries: int = 10,
|
|
71
|
+
retry_interval: int = 5
|
|
72
|
+
) -> Dict:
|
|
73
|
+
"""
|
|
74
|
+
验证域名并等待证书签发完成
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
domain: 要验证的域名
|
|
78
|
+
max_retries: 最大重试次数(当download_url为空时)
|
|
79
|
+
retry_interval: 重试间隔(秒)
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
包含验证结果的字典
|
|
83
|
+
"""
|
|
84
|
+
url = f"{self.BASE_URL}/verify"
|
|
85
|
+
|
|
86
|
+
params = {
|
|
87
|
+
"api_key": self.api_key,
|
|
88
|
+
"domain": domain
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
try:
|
|
92
|
+
response = self.session.get(url, params=params)
|
|
93
|
+
response.raise_for_status()
|
|
94
|
+
result = response.json()
|
|
95
|
+
|
|
96
|
+
# 如果验证成功但download_url为空,需要重试
|
|
97
|
+
if (result.get("success") and
|
|
98
|
+
result.get("data", {}).get("download_url") == "" and
|
|
99
|
+
max_retries > 0):
|
|
100
|
+
time.sleep(retry_interval)
|
|
101
|
+
return self.verify_domain(domain, max_retries - 1, retry_interval)
|
|
102
|
+
|
|
103
|
+
return result
|
|
104
|
+
except requests.exceptions.RequestException as e:
|
|
105
|
+
return {
|
|
106
|
+
"success": False,
|
|
107
|
+
"message": f"请求失败: {str(e)}",
|
|
108
|
+
"error": str(e)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
def get_certificate_info(self, domain: str) -> Dict:
|
|
112
|
+
"""
|
|
113
|
+
获取证书信息
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
domain: 域名
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
包含证书信息的字典,证书内容中的\n会被自动删除
|
|
120
|
+
"""
|
|
121
|
+
url = f"{self.BASE_URL}/get_info"
|
|
122
|
+
|
|
123
|
+
params = {
|
|
124
|
+
"api_key": self.api_key,
|
|
125
|
+
"domain": domain
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
try:
|
|
129
|
+
response = self.session.get(url, params=params)
|
|
130
|
+
response.raise_for_status()
|
|
131
|
+
result = response.json()
|
|
132
|
+
|
|
133
|
+
# 移除证书内容中的\n(包括转义的\n和实际的换行符)
|
|
134
|
+
if result.get("success") and "data" in result:
|
|
135
|
+
data = result["data"]
|
|
136
|
+
for key in ["crt_pem", "crt_key", "crt_bundle"]:
|
|
137
|
+
if key in data and isinstance(data[key], str):
|
|
138
|
+
# 删除转义的\n和实际的换行符
|
|
139
|
+
data[key] = data[key].replace("\\n", "").replace("\n", "")
|
|
140
|
+
|
|
141
|
+
return result
|
|
142
|
+
except requests.exceptions.RequestException as e:
|
|
143
|
+
return {
|
|
144
|
+
"success": False,
|
|
145
|
+
"message": f"请求失败: {str(e)}",
|
|
146
|
+
"error": str(e)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
def create_and_verify(
|
|
150
|
+
self,
|
|
151
|
+
certificate_domain: str,
|
|
152
|
+
channel_type: Literal["zerossl", "letsencrypt", "google"] = "zerossl",
|
|
153
|
+
validation_method: str = "DNS",
|
|
154
|
+
max_retries: int = 10,
|
|
155
|
+
retry_interval: int = 5
|
|
156
|
+
) -> Dict:
|
|
157
|
+
"""
|
|
158
|
+
一键申请并验证证书(便捷方法)
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
certificate_domain: 需要验证的域名
|
|
162
|
+
channel_type: 证书品牌
|
|
163
|
+
validation_method: 验证方式
|
|
164
|
+
max_retries: 验证最大重试次数
|
|
165
|
+
retry_interval: 重试间隔(秒)
|
|
166
|
+
|
|
167
|
+
Returns:
|
|
168
|
+
包含完整流程结果的字典
|
|
169
|
+
"""
|
|
170
|
+
# 第一步:申请证书
|
|
171
|
+
create_result = self.create_certificate(
|
|
172
|
+
certificate_domain=certificate_domain,
|
|
173
|
+
channel_type=channel_type,
|
|
174
|
+
validation_method=validation_method
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
if not create_result.get("success"):
|
|
178
|
+
return create_result
|
|
179
|
+
|
|
180
|
+
# 第二步:验证域名
|
|
181
|
+
verify_result = self.verify_domain(
|
|
182
|
+
domain=certificate_domain,
|
|
183
|
+
max_retries=max_retries,
|
|
184
|
+
retry_interval=retry_interval
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
"create_result": create_result,
|
|
189
|
+
"verify_result": verify_result,
|
|
190
|
+
"success": verify_result.get("success", False)
|
|
191
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fastssl
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: FastSSL - SSL证书管理SDK,支持申请、验证和获取SSL证书
|
|
5
|
+
Author: FastSSL Team
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yourusername/fastssl
|
|
8
|
+
Project-URL: Documentation, https://github.com/yourusername/fastssl
|
|
9
|
+
Project-URL: Repository, https://github.com/yourusername/fastssl
|
|
10
|
+
Keywords: ssl,certificate,ssl-certificate,zerossl,letsencrypt
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
16
|
+
Classifier: Topic :: Security
|
|
17
|
+
Requires-Python: >=3.14
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: requests>=2.31.0
|
|
20
|
+
|
|
21
|
+
# FastSSL
|
|
22
|
+
|
|
23
|
+
FastSSL 是一个用于管理SSL证书的Python SDK,支持申请、验证和获取SSL证书。
|
|
24
|
+
|
|
25
|
+
签发密钥获取渠道:ssl.aa1.cn/user/
|
|
26
|
+
## 安装
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install fastssl
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 快速开始
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from fastssl import FastSSLClient
|
|
36
|
+
|
|
37
|
+
# 初始化客户端
|
|
38
|
+
client = FastSSLClient(api_key="your_api_key")
|
|
39
|
+
|
|
40
|
+
# 申请SSL证书
|
|
41
|
+
result = client.create_certificate(
|
|
42
|
+
certificate_domain="example.com",
|
|
43
|
+
channel_type="zerossl", # 可选: zerossl, letsencrypt, google
|
|
44
|
+
validation_method="DNS"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# 验证域名
|
|
48
|
+
verify_result = client.verify_domain(domain="example.com")
|
|
49
|
+
|
|
50
|
+
# 获取证书信息
|
|
51
|
+
cert_info = client.get_certificate_info(domain="example.com")
|
|
52
|
+
|
|
53
|
+
# 一键申请并验证(便捷方法)
|
|
54
|
+
full_result = client.create_and_verify(
|
|
55
|
+
certificate_domain="example.com",
|
|
56
|
+
channel_type="zerossl"
|
|
57
|
+
)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## API 文档
|
|
61
|
+
|
|
62
|
+
### FastSSLClient
|
|
63
|
+
|
|
64
|
+
#### `__init__(api_key: str)`
|
|
65
|
+
|
|
66
|
+
初始化FastSSL客户端。
|
|
67
|
+
|
|
68
|
+
**参数:**
|
|
69
|
+
- `api_key`: API密钥
|
|
70
|
+
|
|
71
|
+
#### `create_certificate(certificate_domain: str, channel_type: str = "zerossl", validation_method: str = "DNS")`
|
|
72
|
+
|
|
73
|
+
申请SSL证书。
|
|
74
|
+
|
|
75
|
+
**参数:**
|
|
76
|
+
- `certificate_domain`: 需要验证的域名
|
|
77
|
+
- `channel_type`: 证书品牌,可选值: `zerossl`, `letsencrypt`, `google`
|
|
78
|
+
- `validation_method`: 验证方式,默认为 `DNS`
|
|
79
|
+
|
|
80
|
+
**返回:** 包含证书申请结果的字典
|
|
81
|
+
|
|
82
|
+
#### `verify_domain(domain: str, max_retries: int = 10, retry_interval: int = 5)`
|
|
83
|
+
|
|
84
|
+
验证域名并等待证书签发完成。如果验证成功但download_url为空,会自动重试。
|
|
85
|
+
|
|
86
|
+
**参数:**
|
|
87
|
+
- `domain`: 要验证的域名
|
|
88
|
+
- `max_retries`: 最大重试次数(当download_url为空时)
|
|
89
|
+
- `retry_interval`: 重试间隔(秒)
|
|
90
|
+
|
|
91
|
+
**返回:** 包含验证结果的字典
|
|
92
|
+
|
|
93
|
+
#### `get_certificate_info(domain: str)`
|
|
94
|
+
|
|
95
|
+
获取证书信息,自动处理证书内容中的换行符。
|
|
96
|
+
|
|
97
|
+
**参数:**
|
|
98
|
+
- `domain`: 域名
|
|
99
|
+
|
|
100
|
+
**返回:** 包含证书信息的字典
|
|
101
|
+
|
|
102
|
+
#### `create_and_verify(certificate_domain: str, channel_type: str = "zerossl", validation_method: str = "DNS", max_retries: int = 10, retry_interval: int = 5)`
|
|
103
|
+
|
|
104
|
+
一键申请并验证证书的便捷方法。
|
|
105
|
+
|
|
106
|
+
**参数:**
|
|
107
|
+
- `certificate_domain`: 需要验证的域名
|
|
108
|
+
- `channel_type`: 证书品牌
|
|
109
|
+
- `validation_method`: 验证方式
|
|
110
|
+
- `max_retries`: 验证最大重试次数
|
|
111
|
+
- `retry_interval`: 重试间隔(秒)
|
|
112
|
+
|
|
113
|
+
**返回:** 包含完整流程结果的字典
|
|
114
|
+
|
|
115
|
+
## 示例
|
|
116
|
+
|
|
117
|
+
### 基本使用
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from fastssl import FastSSLClient
|
|
121
|
+
|
|
122
|
+
client = FastSSLClient(api_key="your_api_key")
|
|
123
|
+
|
|
124
|
+
# 申请证书
|
|
125
|
+
create_result = client.create_certificate(
|
|
126
|
+
certificate_domain="example.com",
|
|
127
|
+
channel_type="zerossl"
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
if create_result.get("success"):
|
|
131
|
+
print("证书申请成功!")
|
|
132
|
+
print(f"验证信息: {create_result.get('data', {}).get('verify_info')}")
|
|
133
|
+
|
|
134
|
+
# 验证域名
|
|
135
|
+
verify_result = client.verify_domain("example.com")
|
|
136
|
+
|
|
137
|
+
if verify_result.get("success"):
|
|
138
|
+
print("证书验证成功!")
|
|
139
|
+
print(f"下载地址: {verify_result.get('data', {}).get('download_url')}")
|
|
140
|
+
|
|
141
|
+
# 获取证书信息
|
|
142
|
+
cert_info = client.get_certificate_info("example.com")
|
|
143
|
+
if cert_info.get("success"):
|
|
144
|
+
print("证书内容:")
|
|
145
|
+
print(cert_info.get("data", {}).get("crt_pem"))
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 一键申请并验证
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from fastssl import FastSSLClient
|
|
152
|
+
|
|
153
|
+
client = FastSSLClient(api_key="your_api_key")
|
|
154
|
+
|
|
155
|
+
result = client.create_and_verify(
|
|
156
|
+
certificate_domain="example.com",
|
|
157
|
+
channel_type="zerossl",
|
|
158
|
+
max_retries=15, # 最多重试15次
|
|
159
|
+
retry_interval=10 # 每次间隔10秒
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
if result.get("success"):
|
|
163
|
+
verify_data = result.get("verify_result", {}).get("data", {})
|
|
164
|
+
print(f"证书编号: {verify_data.get('certificate_no')}")
|
|
165
|
+
print(f"下载地址: {verify_data.get('download_url')}")
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 许可证
|
|
169
|
+
|
|
170
|
+
MIT License
|
|
171
|
+
|
|
172
|
+
## 支持
|
|
173
|
+
|
|
174
|
+
如有问题或建议,请提交Issue。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests>=2.31.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fastssl
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fastssl"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "FastSSL - SSL证书管理SDK,支持申请、验证和获取SSL证书"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.14"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "FastSSL Team"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["ssl", "certificate", "ssl-certificate", "zerossl", "letsencrypt"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.14",
|
|
21
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
22
|
+
"Topic :: Security",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
dependencies = [
|
|
26
|
+
"requests>=2.31.0",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/yourusername/fastssl"
|
|
31
|
+
Documentation = "https://github.com/yourusername/fastssl"
|
|
32
|
+
Repository = "https://github.com/yourusername/fastssl"
|
|
33
|
+
|
|
34
|
+
[tool.setuptools]
|
|
35
|
+
packages = ["fastssl"]
|
|
36
|
+
|
|
37
|
+
[tool.setuptools.package-data]
|
|
38
|
+
fastssl = ["py.typed"]
|
fastssl-0.1.0/setup.cfg
ADDED