Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

希望添加SSL证书挂载目录 #112

Open
wodeupan1 opened this issue Dec 31, 2024 · 3 comments
Open

希望添加SSL证书挂载目录 #112

wodeupan1 opened this issue Dec 31, 2024 · 3 comments

Comments

@wodeupan1
Copy link

因为没有公网80和443端口,现阶段无法使用南墙代替acme。
但南墙手动添加的证书是写入数据库中,无法通过替换文件的方式更新最新的证书。
希望能给个文件目录,系统自动将目录中的证书导入到数据库。

@Safe3
Copy link
Owner

Safe3 commented Dec 31, 2024

我们会视情况而定

@21307369
Copy link

https://gitee.com/lsmir2/docker-uuwaf 我做了处理
data/updateWafssl 程序可以更新数据库证书

#配置路径
wafupdate=/opt/docker/docker-uuwaf/data/updateWafssl 
#修改证书的路径, sql 账号密码 
$wafupdate -n "server.crt"   -k "server.key"  -s "uuwaf:[email protected]:3306/uuwaf" --id 1

@wodeupan1
Copy link
Author

wodeupan1 commented Jan 6, 2025

抛砖引玉吧,写了个python脚本,青龙面板每个月执行一次

from datetime import datetime
import os
import requests
import json
import time

# 读取当前目录下指定文件名的文件,返回字符串
def read_file(filename):
    return open(os.path.join(os.path.dirname(__file__), filename), 'r').read()

# 提取acme证书目录配置中的时间戳
def get_time(time):
    return time.split('Le_CertCreateTime')[1].split('\'')[1]

cert = read_file('fullchain.cer')
key = read_file('com.key')
dt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(get_time(read_file('com.conf')))))
ct= datetime.now().strftime('%Y-%m-%d %H:%M:%S')

# 组合成请求体
post_json = {
    "id": "0",
    "sni": "[\"*.证书域名.com\",\"证书域名.com\"]",
    "cert": cert,
    "key": key,
    "expire_time": dt,
    "update_time": ct
}


pwd = '{"usr":"南墙管理员","pwd":"密码","otp":""}'

# 获取token
token = requests.post('https://192.168.20.112:4443/api/v1/users/login',data=pwd,verify=False).json()['token']

# 提交证书数据
requests.post('https://192.168.20.112:4443/api/v1/certs/config',data=json.dumps(post_json),headers={"authorization": token},verify=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants