通过域名 ID 查询证书信息¶
1. 接口描述¶
接口请求路径:GET /prod-api/cdn/layer7/ssl/describeSSLByDomain
describeSSLByDomain 用于根据域名 ID,查询与该域名匹配的托管证书列表(证书 SANs 需覆盖该域名或其主域通配符)。
Token 获取方式见 密钥鉴权。
2. 输入参数¶
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| domainId | 是 | Integer | Query 参数。域名 ID 示例值: 194 |
3. 示例¶
示例1 查询域名匹配的托管证书¶
输入示例¶
代码调用¶
请将 {登录域名}、token 替换为实际值。
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class DescribeSSLByDomainTest {
public static void main(String[] args) throws Exception {
String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";
URIBuilder uriBuilder = new URIBuilder("https://{登录域名}/prod-api/cdn/layer7/ssl/describeSSLByDomain");
uriBuilder.addParameter("domainId", "194");
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet(uriBuilder.build());
httpGet.setHeader("Authorization", "Bearer " + token);
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
int statusCode = response.getStatusLine().getStatusCode();
String body = EntityUtils.toString(response.getEntity(), "UTF-8");
System.out.println("Status Code: " + statusCode);
System.out.println("Body: " + body);
}
}
}
}
package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"
u, err := url.Parse("https://{登录域名}/prod-api/cdn/layer7/ssl/describeSSLByDomain")
if err != nil {
panic(err)
}
q := u.Query()
q.Set("domainId", "194")
u.RawQuery = q.Encode()
req, err := http.NewRequest(http.MethodGet, u.String(), nil)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println("Status Code:", resp.StatusCode)
fmt.Println("Body:", string(body))
}
输出示例¶
{
"msg": "操作成功",
"code": 200,
"data": [
{
"alias": "*.demo.com",
"id": 70,
"label": "*.demo.com",
"status": 0,
"subjectDN": "*.demo.com",
"endTime": "2025-07-01 19:41:53"
}
]
}
4. 输出参数¶
| 参数名称 | 类型 | 描述 |
|---|---|---|
| code | Integer | 状态码。示例值:200 |
| msg | String | 提示信息。示例值:操作成功 |
| data | [MatchedHostingCert] | 与该域名匹配的托管证书列表 |
5. 错误码¶
| HTTP 状态码 / 业务提示 | 描述 |
|---|---|
| 200 | 成功 |
| 401 | 未鉴权或 Token 无效 |
| 403 | 无权限 |
| 失败:域名不存在 | domainId 不存在或不属于当前账号 |
6. 数据模型¶
MatchedHostingCert¶
匹配的托管证书。
| 参数名称 | 类型 | 描述 |
|---|---|---|
| id | Integer | 证书 ID。示例值:70 |
| alias | String | 证书别名。示例值:*.demo.com |
| label | String | 展示名称,优先别名。示例值:*.demo.com |
| subjectDN | String | 证书主题。示例值:*.demo.com |
| status | Integer | 证书状态。示例值:0 |
| endTime | String | 到期时间。示例值:2025-07-01 19:41:53 |