# nginxWebUI

## 2. 证书接口

### 2.1. 获取证书分页列表

URL: /api/cert/getPage

Type: GET

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

Description: 获取证书分页列表

Query-parameters:

Parameter | Type | Description | Required | Since
--- | --- | --- | --- | ---
current | int32 | 当前页数(从1开始) | true | -
limit | int32 | 每页数量(默认为10) | true | -
keywords | string | 查询关键字 | false | -

Request-example:

    curl -X GET -i /api/cert/getPage?current=1&limit=10&keywords=

Response-fields:

Field | Type | Description | Since
--- | --- | --- | ---
success | boolean | 请求结果 | -
status | string | 请求状态 200:请求成功 401:token无效 500:服务器错误 | -
msg | string | 错误信息 | -
obj | object | 返回内容 | -
└─count | int64 | 总记录数 | -
└─curr | int32 | 起始页(从1开始) | -
└─limit | int32 | 每页记录数 | -
└─records | array | 列表内容 | -
└─any object | object | any object. | -

Response-example:

    {
      "success": true,
      "status": "",
      "msg": "",
      "obj": {
        "count": 0,
        "curr": 0,
        "limit": 0,
        "records": [
          {
            "id": "",
            "domain": "",
            "pem": "",
            "key": "",
            "type": 0,
            "encryption": "",
            "makeTime": 0,
            "endTime": 0,
            "autoRenew": 0,
            "dnsType": "",
            "dpId": "",
            "dpKey": "",
            "tencentSecretId": "",
            "tencentSecretKey": "",
            "aliKey": "",
            "aliSecret": "",
            "cfEmail": "",
            "cfKey": "",
            "gdKey": "",
            "gdSecret": "",
            "hwUsername": "",
            "hwPassword": "",
            "hwDomainName": "",
            "awsAccessKeyId": "",
            "awsSecretAccessKey": "",
            "ipv64Token": ""
          }
        ]
      }
    }

### 2.2. 添加或编辑证书

URL: /api/cert/addOver

Type: GET

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

Description: 添加或编辑证书

Query-parameters:

Parameter | Type | Description | Required | Since
--- | --- | --- | --- | ---
id | string | 主键 | false | -
domain | string | 域名 | false | -
pem | string | pem文件路径 | false | -
key | string | key文件路径 | false | -
type | int32 | 获取方式 0 申请证书 1 手动上传 2 DNS验证 | false | -
encryption | string | 加密方式 'RSA' 'ECC' | false | -
makeTime | int64 | 签发时间戳 | false | -
endTime | int64 | 到期时间戳 | false | -
autoRenew | int32 | 是否自动续签 0否 1是 | false | -
dnsType | string | dns提供商 ali:阿里云 dp:dnsPod cf:Cloudflare gd:Godaddy hw:华为云 tencent:腾讯云 aws:亚马逊云 ipv64:IPv64 | false | -
dpId | string | dpId(dnsPod需要的参数) | false | -
dpKey | string | dpKey(dnsPod需要的参数) | false | -
tencentSecretId | string | tencentSecretId(腾讯云需要的参数) | false | -
tencentSecretKey | string | tencentSecretKey(腾讯云需要的参数) | false | -
aliKey | string | aliKey(阿里云需要的参数) | false | -
aliSecret | string | aliSecret(阿里云需要的参数) | false | -
cfEmail | string | cfEmail(Cloudflare需要的参数) | false | -
cfKey | string | cfKey(Cloudflare需要的参数) | false | -
gdKey | string | gdKey(Godaddy需要的参数) | false | -
gdSecret | string | gdSecret(Godaddy需要的参数) | false | -
hwUsername | string | hwUsername(华为云需要的参数) | false | -
hwPassword | string | hwPassword(华为云需要的参数) | false | -
hwDomainName | string | hwProjectID(华为云需要的参数) | false | -
awsAccessKeyId | string | AWS_ACCESS_KEY_ID(亚马逊云需要的参数) | false | -
awsSecretAccessKey | string | AWS_SECRET_ACCESS_KEY(亚马逊云需要的参数) | false | -
ipv64Token | string | IPv64_Token(IPv64需要的参数) | false | -

Request-example:

    curl -X GET -i /api/cert/addOver?type=0&makeTime=0&endTime=0&autoRenew=0&aliKey=&dpKey=&encryption=&cfEmail=&pem=&hwPassword=&tencentSecretKey=&tencentSecretId=&dnsType=&key=&gdSecret=&cfKey=&dpId=&gdKey=&aliSecret=&domain=&id=&ipv64Token=&awsSecretAccessKey=&hwUsername=&hwDomainName=&awsAccessKeyId=

Response-fields:

Field | Type | Description | Since
--- | --- | --- | ---
success | boolean | 请求结果 | -
status | string | 请求状态 200:请求成功 401:token无效 500:服务器错误 | -
msg | string | 错误信息 | -
obj | object | 返回内容 | -

Response-example:

    {
      "success": true,
      "status": "",
      "msg": "",
      "obj": {}
    }

### 2.3. 获取域名解析码

URL: /api/cert/getTxtValue

Type: GET

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

Description: 获取域名解析码

Query-parameters:

Parameter | Type | Description | Required | Since
--- | --- | --- | --- | ---
certId | string | 证书id | false | -

Request-example:

    curl -X GET -i /api/cert/getTxtValue?certId=

Response-fields:

Field | Type | Description | Since
--- | --- | --- | ---
success | boolean | 请求结果 | -
status | string | 请求状态 200:请求成功 401:token无效 500:服务器错误 | -
msg | string | 错误信息 | -
obj | object | 返回内容 | -

Response-example:

    {
      "success": true,
      "status": "",
      "msg": "",
      "obj": {}
    }

### 2.4. 设置证书自动续签

URL: /api/cert/setAutoRenew

Type: GET

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

Description: 设置证书自动续签

Query-parameters:

Parameter | Type | Description | Required | Since
--- | --- | --- | --- | ---
id | string | 证书id | false | -
autoRenew | int32 | 是否自动续签:0否 1是 | false | -

Request-example:

    curl -X GET -i /api/cert/setAutoRenew?autoRenew=0&id=

Response-fields:

Field | Type | Description | Since
--- | --- | --- | ---
success | boolean | 请求结果 | -
status | string | 请求状态 200:请求成功 401:token无效 500:服务器错误 | -
msg | string | 错误信息 | -
obj | object | 返回内容 | -

Response-example:

    {
      "success": true,
      "status": "",
      "msg": "",
      "obj": {}
    }

### 2.5. 删除证书

URL: /api/cert/del

Type: GET

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

Description: 删除证书

Query-parameters:

Parameter | Type | Description | Required | Since
--- | --- | --- | --- | ---
id | string | 证书id | false | -

Request-example:

    curl -X GET -i /api/cert/del?id=

Response-fields:

Field | Type | Description | Since
--- | --- | --- | ---
success | boolean | 请求结果 | -
status | string | 请求状态 200:请求成功 401:token无效 500:服务器错误 | -
msg | string | 错误信息 | -
obj | object | 返回内容 | -

Response-example:

    {
      "success": true,
      "status": "",
      "msg": "",
      "obj": {}
    }

### 2.6. 执行申请

URL: /api/cert/apply

Type: GET

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

Description: 执行申请

Query-parameters:

Parameter | Type | Description | Required | Since
--- | --- | --- | --- | ---
id | string | 证书id | false | -
type | string | 申请类型 issue:申请 renew:续签 | false | -

Request-example:

    curl -X GET -i /api/cert/apply?id=&type=

Response-fields:

Field | Type | Description | Since
--- | --- | --- | ---
success | boolean | 请求结果 | -
status | string | 请求状态 200:请求成功 401:token无效 500:服务器错误 | -
msg | string | 错误信息 | -
obj | array | 返回内容 | -
└─id | string | 主键 | -
└─certId | string | 证书id | -
└─domain | string | 域名 | -
└─type | string | 解析类型 | -
└─value | string | 解析值 | -

Response-example:

    {
      "success": true,
      "status": "",
      "msg": "",
      "obj": [
        {
          "id": "",
          "certId": "",
          "domain": "",
          "type": "",
          "value": ""
        }
      ]
    }

### 2.7. 下载证书文件

URL: /api/cert/download

Type: GET

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

Description: 下载证书文件

Query-parameters:

Parameter | Type | Description | Required | Since
--- | --- | --- | --- | ---
id | string | 证书id | false | -

Request-example:

    curl -X GET -i /api/cert/download?id=

Response-fields:

Field | Type | Description | Since
--- | --- | --- | ---
contentType | string | 内容类型（有些地方会动态构建，所以不能只读） | -
contentSize | int64 | 内容大小 | -
content | object | 内容流 | -
name | string | 文件名（带扩展名，例：demo.jpg） | -

Response-example:

    File download.