sslbear-cli 0.0.0-stage → 0.1.0
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.
- package/README.md +120 -2
- package/dist/index.js +4362 -0
- package/package.json +38 -4
package/README.md
CHANGED
|
@@ -1,3 +1,121 @@
|
|
|
1
|
-
#
|
|
1
|
+
# sslbear-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
证书熊([sslbear.com](https://sslbear.com))命令行工具:一条命令查出阿里云、腾讯云各云服务上配置的域名,以及每个域名当前绑定的 SSL 证书和到期时间。
|
|
4
|
+
|
|
5
|
+
- 零安装:`npx sslbear-cli ...` 即可运行(Node.js ≥ 18.17),发布包不带任何运行时依赖
|
|
6
|
+
- 只读:只调用查询类接口,不会修改任何云上配置
|
|
7
|
+
- 凭证从环境变量读取,也支持当前目录的 `.env` 文件
|
|
8
|
+
|
|
9
|
+
## 快速开始
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
export ALIBABA_CLOUD_ACCESS_KEY_ID=LTAI...
|
|
13
|
+
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=...
|
|
14
|
+
export TENCENTCLOUD_SECRET_ID=AKID...
|
|
15
|
+
export TENCENTCLOUD_SECRET_KEY=...
|
|
16
|
+
|
|
17
|
+
npx sslbear-cli env # 检查凭证配置
|
|
18
|
+
npx sslbear-cli domains # 所有云服务域名及证书,按剩余天数升序
|
|
19
|
+
npx sslbear-cli domains -e 30 # 只看 30 天内到期(含已过期)的
|
|
20
|
+
npx sslbear-cli certs # 证书服务里的证书列表
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
输出示例:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
云厂商 服务 域名 HTTPS 证书 到期时间 剩余天数
|
|
27
|
+
腾讯云 CDN static.example.cn 开启 static-cert 2026-10-12 已过期 3 天
|
|
28
|
+
阿里云 对象存储 OSS img.example.com 开启 12345-cn-hangzhou 2026-11-02 18
|
|
29
|
+
阿里云 CDN api.example.com 开启 api-2026 2027-01-12 89
|
|
30
|
+
腾讯云 EdgeOne www.example.io 关闭 - - -
|
|
31
|
+
|
|
32
|
+
共 4 个域名,1 个证书已过期,1 个 30 天内到期,1 个未开启 HTTPS
|
|
33
|
+
提示:aliyun/dcdn 未开通或无资源(DcdnServiceNotFound)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
表格里的到期时间按本机时区显示。
|
|
37
|
+
|
|
38
|
+
## 配置
|
|
39
|
+
|
|
40
|
+
| 环境变量 | 说明 |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `ALIBABA_CLOUD_ACCESS_KEY_ID` | 阿里云 AccessKey ID(别名 `ALIYUN_ACCESS_KEY_ID`) |
|
|
43
|
+
| `ALIBABA_CLOUD_ACCESS_KEY_SECRET` | 阿里云 AccessKey Secret(别名 `ALIYUN_ACCESS_KEY_SECRET`) |
|
|
44
|
+
| `ALIBABA_CLOUD_SECURITY_TOKEN` | 可选,使用 STS 临时凭证时设置 |
|
|
45
|
+
| `TENCENTCLOUD_SECRET_ID` | 腾讯云 SecretId |
|
|
46
|
+
| `TENCENTCLOUD_SECRET_KEY` | 腾讯云 SecretKey |
|
|
47
|
+
| `TENCENTCLOUD_SESSION_TOKEN` | 可选,使用临时凭证时设置 |
|
|
48
|
+
|
|
49
|
+
- 只配置了一家云厂商也可以,命令默认只查已配置凭证的云厂商。
|
|
50
|
+
- 当前目录有 `.env` 时会自动加载;`--env-file <path>` 可指定其他文件。shell 里已设置的变量优先:只要 shell 里设置了某家云厂商的任一凭证变量,`.env` 里这家的凭证就整组忽略,不会把两处的 ID、Secret 拼成一组。
|
|
51
|
+
- 建议用 RAM 子账号 / CAM 子用户,只授予只读权限(见下文「所需权限」)。
|
|
52
|
+
|
|
53
|
+
## 命令
|
|
54
|
+
|
|
55
|
+
### `domains`:云服务域名及其证书
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
sslbear-cli domains [选项]
|
|
59
|
+
-p, --provider <list> 只查指定云厂商:aliyun, tencent
|
|
60
|
+
-s, --service <list> 只查指定服务,见下表
|
|
61
|
+
-d, --domain <keyword> 按域名关键字过滤(同时匹配证书的通用名和 SAN)
|
|
62
|
+
-e, --expiring-within <days> 只看 N 天内到期(含已过期)的证书
|
|
63
|
+
--timeout <ms> 单个请求超时,默认 15000
|
|
64
|
+
--json 输出单行 JSON
|
|
65
|
+
--env-file <path> 从指定文件加载环境变量
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| 云厂商 | `--service` | 云服务 |
|
|
69
|
+
| --- | --- | --- |
|
|
70
|
+
| aliyun | `cdn` | CDN |
|
|
71
|
+
| aliyun | `dcdn` | 全站加速 DCDN |
|
|
72
|
+
| aliyun | `oss` | 对象存储 OSS(自定义域名) |
|
|
73
|
+
| aliyun | `live` | 视频直播 |
|
|
74
|
+
| aliyun | `vod` | 视频点播 |
|
|
75
|
+
| tencent | `cdn` | CDN |
|
|
76
|
+
| tencent | `teo` | EdgeOne |
|
|
77
|
+
| tencent | `live` | 云直播 |
|
|
78
|
+
| tencent | `vod` | 云点播 |
|
|
79
|
+
|
|
80
|
+
### `certs`:证书服务里的证书
|
|
81
|
+
|
|
82
|
+
列出阿里云数字证书管理服务(SSL 证书)和腾讯云 SSL 证书中的证书,同样支持 `-p`、`-d`、`-e`、`--json`。
|
|
83
|
+
|
|
84
|
+
### `env`:检查配置
|
|
85
|
+
|
|
86
|
+
显示每家云厂商的凭证是否配置齐全(AccessKey ID 脱敏显示,Secret 只显示「已设置」)以及可查询的服务。
|
|
87
|
+
|
|
88
|
+
## JSON 输出与退出码
|
|
89
|
+
|
|
90
|
+
加 `--json` 后输出单行 JSON,便于脚本和 agent 解析:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{"ok":true,"data":{"items":[{"provider":"aliyun","service":"oss","domain":"img.example.com","status":"Enabled","https":true,"cert":{"id":"12345-cn-hangzhou","notAfter":"2026-11-02T10:14:51.000Z","status":"Enabled"},"extra":{"bucket":"static-prod","region":"cn-shanghai","certType":"CAS"},"daysLeft":18}],"issues":[{"provider":"aliyun","service":"dcdn","kind":"inactive","code":"DcdnServiceNotFound","message":"The DCDN service is not activated."}]}}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
- 时间字段统一为 ISO 8601(UTC),`daysLeft` 为剩余天数,负数表示已过期。
|
|
97
|
+
- 各云服务返回的字段不完全一致,`cert` 里只输出该服务实际提供的字段(如 OSS 只有证书 ID 和有效期,没有证书名)。
|
|
98
|
+
- `issues` 记录各服务的查询问题:`kind: "inactive"` 表示该服务未开通或无资源,`kind: "error"` 表示调用失败(含错误码和 RequestId);逐个 bucket / 站点 / 应用展开查询的服务,单个子项失败时用 `target` 标明是哪一个,其余子项照常返回。
|
|
99
|
+
- 退出码:`0` 成功(部分服务失败时仍返回 0,详情见 `issues`);`1` 所有查询都失败(如凭证无效、网络不通);`2` 参数或凭证配置错误。失败时 stderr 输出 `{"ok":false,"status":...,"message":"..."}`。
|
|
100
|
+
|
|
101
|
+
## 所需权限
|
|
102
|
+
|
|
103
|
+
只需各产品的只读权限,可在 RAM / CAM 控制台给子账号授予对应产品的 ReadOnly 系统策略(CDN、DCDN、OSS、视频直播、视频点播、数字证书管理服务;腾讯云 CDN、EdgeOne、云直播、云点播、SSL 证书)。腾讯云直播、点播里只返回证书 ID 的域名,会用 SSL 证书列表补全到期时间,因此建议同时授予 SSL 证书只读权限。
|
|
104
|
+
|
|
105
|
+
缺少某个服务的权限时,只有该服务会出现在 `issues` 里,其余服务照常输出。
|
|
106
|
+
|
|
107
|
+
## 已知限制
|
|
108
|
+
|
|
109
|
+
- 阿里云视频点播只查询上海地域(`vod.cn-shanghai.aliyuncs.com`)。
|
|
110
|
+
- 暂不支持腾讯云 COS 自定义域名和阿里云边缘安全加速 ESA。经过 CDN 加速的 COS 域名会出现在腾讯云 CDN 的结果里。
|
|
111
|
+
- 阿里云 CAS 证书列表接口只返回到期日期、不含具体时刻,按到期当天 23:59:59(北京时间)计算剩余天数。
|
|
112
|
+
|
|
113
|
+
## 开发
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm install
|
|
117
|
+
npm test # 单元测试(签名算法用官方示例向量校验,云接口用 mock)
|
|
118
|
+
npm run typecheck
|
|
119
|
+
npm run build # 打包到 dist/index.js
|
|
120
|
+
node dist/index.js domains --help
|
|
121
|
+
```
|