d0e738e1ef11190857d55f8656746538ae15510b
Previously the CreateCertificate handler checked domain existence and then inserted separately, creating a race window where concurrent requests could both pass the check and trigger 'UNIQUE constraint failed' on INSERT. Now uses SQLite's native INSERT ... ON CONFLICT (upsert) which atomically handles the uniqueness constraint at the database level, eliminating the race condition entirely.
AutoSSL - 自动 SSL 证书管理工具
基于 Go 开发的 ACME 自动 SSL 证书申请与管理工具,提供 Web 管理界面。
功能
- ✅ 自动申请 SSL 证书(Let's Encrypt / ZeroSSL)
- ✅ 自动续期(每天凌晨 3 点自动检查并续期)
- ✅ HTTP-01(端口 80)和 DNS-01 验证方式
- ✅ 支持阿里云 DNS / Cloudflare / DNSPod
- ✅ Web 管理界面(仪表盘、证书列表、申请、查看、续期、删除)
- ✅ SQLite 数据存储
- ✅ Docker 一键部署
快速开始
Docker 部署
git clone <your-repo-url> autossl
cd autossl
docker compose up -d
直接运行
# 编译
cd backend && go build -o autossl .
# 运行(默认端口 8080)
./autossl
环境变量
| 变量 | 默认值 | 说明 |
|---|---|---|
| PORT | 8080 | Web 服务端口 |
| DB_PATH | ./data/autossl.db | SQLite 数据库路径 |
| CERT_DIR | ./data/certs | 证书文件存储目录 |
| ACCOUNTS_DIR | ./data/accounts | ACME 账号存储目录 |
API 接口
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /api/stats | 统计信息 |
| GET | /api/certificates | 证书列表 |
| GET | /api/certificates/:id | 证书详情 |
| POST | /api/certificates | 申请证书 |
| PUT | /api/certificates/:id | 更新证书配置 |
| DELETE | /api/certificates/:id | 删除证书 |
| POST | /api/certificates/:id/renew | 手动续期 |
| GET | /api/certificates/:id/files | 查看证书文件 |
| GET | /api/renewals/check | 触发续期检查 |
证书文件位置
申请成功后的证书文件存储在 ./data/certs/<domain>/ 目录:
fullchain.pem- 完整证书链privkey.pem- 私钥chain.pem- CA 证书链
Description