雨云ssl自动证书更新

可以搭配acme.sh使用

Python版

需要安装requests

pip install requests

以下是更新api更新ssl代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import requests
import json

# 读取公钥和私钥文件
with open('你的公钥文件路径', 'r') as cert_file:
cert = cert_file.read().strip()

with open('你的私钥文件路径', 'r') as key_file:
key = key_file.read().strip()


# 设置API密钥
apikey = "你的雨云key"

# 构建请求头
headers = {
'x-api-key': apikey,
'Content-Type': 'application/json',
}

# 构建请求体,直接包含证书和密钥
data = json.dumps({
'cert': cert,
'key': key,
})

# 发送PUT请求
response = requests.put('https://api.v2.rainyun.com/product/sslcenter/9280', headers=headers, data=data)

# 打印响应
print(response.text)

bash版

需要安装curljq

1
2
3
4
5
6
7
8
cert=$(cat 你的公钥文件路径)
key=$(cat 你的私钥文件路径)
apikey=你的雨云key
#更新
curl --location --request PUT 'https://api.v2.rainyun.com/product/sslcenter/9280' \
--header 'x-api-key: '$apikey'' \
--header 'Content-Type: application/json' --data-raw "$(jq -n --arg cert "$cert" --arg key "$key" '{"cert": $cert, "key": $key}')"

雨云 邀请码:hc26

绑定微信获得5元优惠券注册链接:https://www.rainyun.com/hc26_/