获取证书详情或下载证书包
/v1/certs/{cert_id}按证书 ID 获取证书原始详情。普通请求返回包含证书 PEM 和私钥 PEM 的 JSON 记录;传入查询参数 action=download 时改为下载 gzip 压缩包,包内包含以证书域名命名的 .pem 和 .key 文件。普通用户只能读取自己的证书,管理员可读取其他用户证书;该接口会返回私钥,调用方必须在安全环境中使用并妥善保管响应。
身份认证
access-token
api-key + api-secret
认证定义
{
"AccessToken": {
"type": "apiKey",
"in": "header",
"name": "access-token",
"description": "通过登录接口获得的短期访问令牌。"
},
"ApiKey": {
"type": "apiKey",
"in": "header",
"name": "api-key",
"description": "API Key;必须和 api-secret 同时发送。"
},
"ApiSecret": {
"type": "apiKey",
"in": "header",
"name": "api-secret",
"description": "API Secret;必须和 api-key 同时发送。"
}
}请求参数
| 参数 | 位置 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|---|
cert_id | path | integer (int64) | 必填 | 要读取的证书 ID;路由只接受十进制整数。 完整参数定义 |
action | query | string | 可选 | 下载动作开关;传 download 返回 gzip 证书包,省略或传其他值返回 JSON 详情。 完整参数定义 |
响应
HTTP 200
业务结果通过 HTTP 200 返回;普通请求返回 JSON 详情,action=download 返回二进制 gzip 压缩包。记录不存在、读取其他用户证书且当前身份不是管理员或认证失效时,JSON 分支返回字符串业务错误码。
application/json
oneOf
oneOf · 1 · object
| 字段 | 类型 | 必填 | 说明与约束 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code | integer | 必填 | 成功状态码,证书详情读取成功时固定为 0。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
msg | string | 必填 | 详情读取成功时没有提示,JSON 序列化为 null。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data | object | 必填 | 数据库证书详情记录,包含证书和私钥敏感字段。 约束 / 默认值 / 示例展开字段结构数据库证书详情记录,包含证书和私钥敏感字段。
|
oneOf · 2 · object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
code | string | 必填 | 业务错误码:cert-33 表示证书不存在,cert-50 表示当前用户无权读取其他用户证书,login_required 表示认证无效。 约束 / 默认值 / 示例 |
msg | string | 必填 | 与业务错误码对应的中文记录不存在、权限或认证失败原因。 |
data | string | 必填 | 业务错误时固定为空字符串。 约束 / 默认值 / 示例 |
完整 Schema
{
"oneOf": [
{
"type": "object",
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"enum": [
0
],
"description": "成功状态码,证书详情读取成功时固定为 0。"
},
"msg": {
"type": "string",
"nullable": true,
"enum": [
null
],
"description": "详情读取成功时没有提示,JSON 序列化为 null。"
},
"data": {
"type": "object",
"required": [
"id",
"uid",
"name",
"des",
"type",
"domain",
"dnsapi",
"cert",
"key",
"start_time",
"expire_time",
"auto_renew",
"create_at",
"update_at",
"enable",
"task_id",
"issue_task_id",
"version"
],
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "证书唯一 ID。"
},
"uid": {
"type": "integer",
"format": "int64",
"description": "证书所属用户 ID。"
},
"name": {
"type": "string",
"description": "证书显示名称。 具体说明"
},
"des": {
"type": "string",
"description": "证书备注,可为空字符串。"
},
"type": {
"type": "string",
"enum": [
"custom",
"lets",
"zerossl",
"buypass"
],
"description": "证书来源类型。 具体说明"
},
"domain": {
"type": "string",
"nullable": true,
"description": "证书覆盖的域名,多个域名以空格分隔;未解析时为 null。"
},
"dnsapi": {
"type": "integer",
"format": "int64",
"nullable": true,
"description": "自动签发使用的 DNS API ID;未指定时为 null。"
},
"cert": {
"type": "string",
"writeOnly": true,
"description": "证书链 PEM 原文;此字段包含敏感材料,示例不得使用真实证书。"
},
"key": {
"type": "string",
"format": "password",
"writeOnly": true,
"description": "证书私钥 PEM 原文;此字段是敏感凭据,示例不得使用真实私钥。"
},
"start_time": {
"type": "string",
"nullable": true,
"pattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$",
"description": "证书生效时间,格式为 YYYY-MM-DD HH:mm:ss;未签发时为 null。"
},
"expire_time": {
"type": "string",
"nullable": true,
"pattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$",
"description": "证书到期时间,格式为 YYYY-MM-DD HH:mm:ss;未签发时为 null。"
},
"auto_renew": {
"type": "integer",
"enum": [
0,
1
],
"description": "自动续签状态:1 启用,0 关闭。"
},
"create_at": {
"type": "string",
"nullable": true,
"pattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$",
"description": "证书记录创建时间,格式为 YYYY-MM-DD HH:mm:ss。"
},
"update_at": {
"type": "string",
"nullable": true,
"pattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$",
"description": "证书记录最后更新时间,格式为 YYYY-MM-DD HH:mm:ss。"
},
"enable": {
"type": "integer",
"enum": [
0,
1
],
"description": "证书启用状态:1 启用,0 禁用。"
},
"task_id": {
"type": "integer",
"format": "int64",
"nullable": true,
"description": "最近一次证书同步或删除任务 ID;没有任务时为 null。"
},
"issue_task_id": {
"type": "integer",
"format": "int64",
"nullable": true,
"description": "自动签发任务 ID;自上传证书没有签发任务时为 null。"
},
"version": {
"type": "integer",
"format": "int64",
"description": "证书配置版本号,每次更新递增。"
}
},
"additionalProperties": false,
"description": "数据库证书详情记录,包含证书和私钥敏感字段。"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "string",
"enum": [
"cert-33",
"cert-50",
"login_required"
],
"description": "业务错误码:cert-33 表示证书不存在,cert-50 表示当前用户无权读取其他用户证书,login_required 表示认证无效。"
},
"msg": {
"type": "string",
"description": "与业务错误码对应的中文记录不存在、权限或认证失败原因。"
},
"data": {
"type": "string",
"enum": [
""
],
"description": "业务错误时固定为空字符串。"
}
},
"additionalProperties": false
}
]
}示例
{
"code": 0,
"msg": null,
"data": {
"id": 10021,
"uid": 2,
"name": "API 证书",
"des": "生产站点",
"type": "lets",
"domain": "api.example.invalid",
"dnsapi": 12,
"cert": "-----BEGIN CERTIFICATE-----\\n<REDACTED>\\n-----END CERTIFICATE-----",
"key": "REDACTED_PRIVATE_KEY_PEM",
"start_time": "2026-06-01 00:00:00",
"expire_time": "2026-08-30 00:00:00",
"auto_renew": 1,
"create_at": "2026-06-01 00:00:00",
"update_at": "2026-06-01 00:05:00",
"enable": 1,
"task_id": null,
"issue_task_id": 20031,
"version": 1
}
}application/gzip
string (binary)
action=download 时返回的 gzip 压缩包,包含域名.pem 和域名.key 两个文件。
完整 Schema
{
"type": "string",
"format": "binary",
"description": "action=download 时返回的 gzip 压缩包,包含域名.pem 和域名.key 两个文件。"
}示例
<binary gzip payload>cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request GET \
"https://master.example.invalid/v1/certs/{cert_id}" \
--header "access-token: YOUR_ACCESS_TOKEN"