itecdn 5.x用户文档
itecdn 5.x / 用户 API

获取证书详情或下载证书包

GET/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_idpathinteger (int64)必填

要读取的证书 ID;路由只接受十进制整数。

完整参数定义
{
  "name": "cert_id",
  "in": "path",
  "required": true,
  "description": "要读取的证书 ID;路由只接受十进制整数。",
  "schema": {
    "type": "integer",
    "format": "int64",
    "minimum": 1
  },
  "example": 10021
}
actionquerystring可选

下载动作开关;传 download 返回 gzip 证书包,省略或传其他值返回 JSON 详情。

完整参数定义
{
  "name": "action",
  "in": "query",
  "required": false,
  "description": "下载动作开关;传 download 返回 gzip 证书包,省略或传其他值返回 JSON 详情。",
  "schema": {
    "type": "string",
    "enum": [
      "download"
    ]
  },
  "example": "download"
}

响应

HTTP 200

业务结果通过 HTTP 200 返回;普通请求返回 JSON 详情,action=download 返回二进制 gzip 压缩包。记录不存在、读取其他用户证书且当前身份不是管理员或认证失效时,JSON 分支返回字符串业务错误码。

application/json

oneOf

oneOf · 1 · object
字段类型必填说明与约束
codeinteger必填

成功状态码,证书详情读取成功时固定为 0。

约束 / 默认值 / 示例
{
  "enum": [
    0
  ]
}
msgstring必填

详情读取成功时没有提示,JSON 序列化为 null。

约束 / 默认值 / 示例
{
  "nullable": true,
  "enum": [
    null
  ]
}
dataobject必填

数据库证书详情记录,包含证书和私钥敏感字段。

约束 / 默认值 / 示例
{
  "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"
  ],
  "additionalProperties": false
}
展开字段结构

数据库证书详情记录,包含证书和私钥敏感字段。

字段类型必填说明与约束
idinteger (int64)必填

证书唯一 ID。

约束 / 默认值 / 示例
{
  "format": "int64"
}
uidinteger (int64)必填

证书所属用户 ID。

约束 / 默认值 / 示例
{
  "format": "int64"
}
namestring必填

证书显示名称。 具体说明

desstring必填

证书备注,可为空字符串。

typestring必填

证书来源类型。 具体说明

约束 / 默认值 / 示例
{
  "enum": [
    "custom",
    "lets",
    "zerossl",
    "buypass"
  ]
}
domainstring必填

证书覆盖的域名,多个域名以空格分隔;未解析时为 null。

约束 / 默认值 / 示例
{
  "nullable": true
}
dnsapiinteger (int64)必填

自动签发使用的 DNS API ID;未指定时为 null。

约束 / 默认值 / 示例
{
  "format": "int64",
  "nullable": true
}
certstring必填

证书链 PEM 原文;此字段包含敏感材料,示例不得使用真实证书。

约束 / 默认值 / 示例
{
  "writeOnly": true
}
keystring (password)必填

证书私钥 PEM 原文;此字段是敏感凭据,示例不得使用真实私钥。

约束 / 默认值 / 示例
{
  "format": "password",
  "writeOnly": true
}
start_timestring必填

证书生效时间,格式为 YYYY-MM-DD HH:mm:ss;未签发时为 null。

约束 / 默认值 / 示例
{
  "nullable": true,
  "pattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$"
}
expire_timestring必填

证书到期时间,格式为 YYYY-MM-DD HH:mm:ss;未签发时为 null。

约束 / 默认值 / 示例
{
  "nullable": true,
  "pattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$"
}
auto_renewinteger必填

自动续签状态:1 启用,0 关闭。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
create_atstring必填

证书记录创建时间,格式为 YYYY-MM-DD HH:mm:ss。

约束 / 默认值 / 示例
{
  "nullable": true,
  "pattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$"
}
update_atstring必填

证书记录最后更新时间,格式为 YYYY-MM-DD HH:mm:ss。

约束 / 默认值 / 示例
{
  "nullable": true,
  "pattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$"
}
enableinteger必填

证书启用状态:1 启用,0 禁用。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
task_idinteger (int64)必填

最近一次证书同步或删除任务 ID;没有任务时为 null。

约束 / 默认值 / 示例
{
  "format": "int64",
  "nullable": true
}
issue_task_idinteger (int64)必填

自动签发任务 ID;自上传证书没有签发任务时为 null。

约束 / 默认值 / 示例
{
  "format": "int64",
  "nullable": true
}
versioninteger (int64)必填

证书配置版本号,每次更新递增。

约束 / 默认值 / 示例
{
  "format": "int64"
}
oneOf · 2 · object
字段类型必填说明与约束
codestring必填

业务错误码:cert-33 表示证书不存在,cert-50 表示当前用户无权读取其他用户证书,login_required 表示认证无效。

约束 / 默认值 / 示例
{
  "enum": [
    "cert-33",
    "cert-50",
    "login_required"
  ]
}
msgstring必填

与业务错误码对应的中文记录不存在、权限或认证失败原因。

datastring必填

业务错误时固定为空字符串。

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
完整 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"

查看完整接口 JSON