Path: API › SSL 证书

`POST /ssl`

将证书夹中已保存的 SSL 证书部署到指定网站，开启 HTTPS。

## Request body

_Required._

- `action325.request_time` (string, required) — Unix 时间戳。
- `action325.request_token` (string, required) — 按 API 概览生成的签名。
- `action325.action` (string, required) — 具体操作名称。
  - one of `"SetCertToSite"`
- `action325.ssl_hash` (string, required) — 证书 hash（通过 `get_cert_list` 获取）
- `action325.siteName` (string, required) — 目标网站域名

## Example request

```text
{
  "request_time": "string",
  "request_token": "string",
  "action": "SetCertToSite",
  "ssl_hash": "string",
  "siteName": "string"
}
```

## Code samples

### cURL（填写面板地址与签名）

```curl
curl --request POST \
  --url "https://your-panel.example.com:8888/ssl" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "request_time=<Unix时间戳>" \
  --data-urlencode "request_token=<按 API 概览生成的签名>" \
  --data-urlencode "action=SetCertToSite" \
  --data-urlencode "ssl_hash=<ssl_hash>" \
  --data-urlencode "siteName=<siteName>"
```

## Responses

### default

接口响应，业务状态见下方详细说明。

#### Example

```json
{
  "status": true,
  "msg": "SSL开启成功!",
  "csr": "-----BEGIN CERTIFICATE-----\n..."
}
```

- `action325.response.default.status` (boolean, optional) — `true` 部署成功
- `action325.response.default.msg` (string, optional) — `SSL开启成功!`
- `action325.response.default.csr` (string, optional) — 部署的证书链（PEM 格式）


## SetCertToSite (SSL)

将证书夹中已保存的 SSL 证书部署到指定网站，开启 HTTPS。

- **路由**：`POST /ssl`
- **action**：`SetCertToSite`

## 输入参数

| 参数名称 | 必选 | 类型 | 描述 |
|----------|------|------|------|
| action | 是 | String | 固定值 `SetCertToSite` |
| ssl_hash | 是 | String | 证书 hash（通过 `get_cert_list` 获取） |
| siteName | 是 | String | 目标网站域名 |

## 输出参数

| 参数名称 | 类型 | 描述 |
|----------|------|------|
| status | Boolean | `true` 部署成功 |
| msg | String | `SSL开启成功!` |
| csr | String | 部署的证书链（PEM 格式） |

## 示例

### 请求

```
POST /ssl HTTP/1.1
Host: 192.168.168.213:8888
Content-Type: application/x-www-form-urlencoded

action=SetCertToSite&ssl_hash=6da02a66c92a01d07b3aab68bf1317e6&siteName=testapi.bt.local
```

### 响应

```json
{"status": true, "msg": "SSL开启成功!", "csr": "-----BEGIN CERTIFICATE-----\n..."}
```

## 相关接口

- [get_cert_list](/api/ssl/get_cert_list) — 获取可用证书列表
- [get_cert_info](/api/ssl/get_cert_info) — 证书详情

