{
  "tags": [
    "证书管理"
  ],
  "description": "按证书 ID 获取证书原始详情。普通请求返回包含证书 PEM 和私钥 PEM 的 JSON 记录；传入查询参数 action=download 时改为下载 gzip 压缩包，包内包含以证书域名命名的 .pem 和 .key 文件。普通用户只能读取自己的证书，管理员可读取其他用户证书；该接口会返回私钥，调用方必须在安全环境中使用并妥善保管响应。",
  "operationId": "user_get_v1_certs_cert_id",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "业务结果通过 HTTP 200 返回；普通请求返回 JSON 详情，action=download 返回二进制 gzip 压缩包。记录不存在、读取其他用户证书且当前身份不是管理员或认证失效时，JSON 分支返回字符串业务错误码。",
      "content": {
        "application/json": {
          "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
              }
            ]
          },
          "example": {
            "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": {
          "schema": {
            "type": "string",
            "format": "binary",
            "description": "action=download 时返回的 gzip 压缩包，包含域名.pem 和域名.key 两个文件。"
          },
          "example": "<binary gzip payload>"
        }
      }
    }
  },
  "x-python-handler": "site.CertAPI",
  "x-python-route-line": 363,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [
    {
      "name": "cert_id",
      "in": "path",
      "required": true,
      "description": "要读取的证书 ID；路由只接受十进制整数。",
      "schema": {
        "type": "integer",
        "format": "int64",
        "minimum": 1
      },
      "example": 10021
    },
    {
      "name": "action",
      "in": "query",
      "required": false,
      "description": "下载动作开关；传 download 返回 gzip 证书包，省略或传其他值返回 JSON 详情。",
      "schema": {
        "type": "string",
        "enum": [
          "download"
        ]
      },
      "example": "download"
    }
  ],
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "site.CertAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 363
    },
    {
      "key": "x-audience",
      "value": "user"
    },
    {
      "key": "x-auth",
      "value": "user"
    },
    {
      "key": "x-reviewed",
      "value": true
    },
    {
      "key": "x-itecdn-source-reviewed",
      "value": true
    }
  ],
  "method": "get",
  "path": "/v1/certs/{cert_id}",
  "servers": [
    {
      "url": "https://master.example.invalid",
      "description": "不可调用的示例地址；复制示例后替换为自己的主控域名。"
    }
  ],
  "securitySchemes": {
    "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 同时发送。"
    }
  },
  "info": {
    "title": "itecdn v5 用户 API",
    "version": "5.x",
    "description": "itecdn v5.x Python 主控用户 API。本文档不适用于 v6 或其它实现。"
  },
  "postman": {
    "name": "获取证书详情或下载证书包",
    "description": {
      "content": "按证书 ID 获取证书原始详情。普通请求返回包含证书 PEM 和私钥 PEM 的 JSON 记录；传入查询参数 action=download 时改为下载 gzip 压缩包，包内包含以证书域名命名的 .pem 和 .key 文件。普通用户只能读取自己的证书，管理员可读取其他用户证书；该接口会返回私钥，调用方必须在安全环境中使用并妥善保管响应。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "certs",
        ":cert_id"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [
        {
          "disabled": false,
          "description": {
            "content": "下载动作开关；传 download 返回 gzip 证书包，省略或传其他值返回 JSON 详情。",
            "type": "text/plain"
          },
          "key": "action",
          "value": ""
        }
      ],
      "variable": [
        {
          "disabled": false,
          "description": {
            "content": "(Required) 要读取的证书 ID；路由只接受十进制整数。",
            "type": "text/plain"
          },
          "type": "any",
          "value": "",
          "key": "cert_id"
        }
      ]
    },
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "method": "GET",
    "auth": {
      "type": "apikey",
      "apikey": [
        {
          "type": "any",
          "value": "access-token",
          "key": "key"
        },
        {
          "type": "any",
          "value": "{{apiKey}}",
          "key": "value"
        },
        {
          "type": "any",
          "value": "header",
          "key": "in"
        }
      ]
    }
  }
}