修改域名证书¶
1. 接口描述¶
接口请求路径:POST /prod-api/multiCdn/ssl/updateCdnDomainSsl
updateCdnDomainSsl 用于为指定域名绑定或更换证书,并同步修改回源协议。请求成功后会生成配置下发任务。账号需具备 cdn2:EditDomain 权限。
Token 获取方式见 密钥鉴权。
2. 输入参数¶
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| domainGrnId | 是 | String | 域名唯一 ID。示例值:grn:test:multi-cdn:001:domain/01234565d940e553de8e |
| originProtocol | 是 | String | 回源协议。取值:http(HTTP)、https(HTTPS)、follow(协议跟随)。示例值:https |
| certGrnId | 否 | String | 证书唯一 ID。不传或传空时仅修改回源协议,不绑定证书。示例值:grn:test:multi-cdn:001:certificate/1a2b3c4d5e6f7890 |
3. 输出参数¶
| 参数名称 | 类型 | 描述 |
|---|---|---|
| code | Integer | 状态码。示例值:200 |
| msg | String | 提示信息。示例值:成功 |
| data | Object | 本接口固定为 null |
4. 示例¶
输入示例¶
{
"domainGrnId": "grn:test:multi-cdn:001:domain/01234565d940e553de8e",
"certGrnId": "grn:test:multi-cdn:001:certificate/1a2b3c4d5e6f7890",
"originProtocol": "https"
}
代码调用¶
请将 {登录域名}、token 替换为实际值。
curl -X POST 'https://{登录域名}/prod-api/multiCdn/ssl/updateCdnDomainSsl' \
-H 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.xxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"domainGrnId": "grn:test:multi-cdn:001:domain/01234565d940e553de8e",
"certGrnId": "grn:test:multi-cdn:001:certificate/1a2b3c4d5e6f7890",
"originProtocol": "https"
}'
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class UpdateCdnDomainSslTest {
public static void main(String[] args) throws Exception {
String url = "https://{登录域名}/prod-api/multiCdn/ssl/updateCdnDomainSsl";
String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";
String requestBody = "{"
+ "\"domainGrnId\":\"grn:test:multi-cdn:001:domain/01234565d940e553de8e\","
+ "\"certGrnId\":\"grn:test:multi-cdn:001:certificate/1a2b3c4d5e6f7890\","
+ "\"originProtocol\":\"https\""
+ "}";
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("Authorization", "Bearer " + token);
httpPost.setEntity(new StringEntity(requestBody, ContentType.APPLICATION_JSON));
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
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 (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://{登录域名}/prod-api/multiCdn/ssl/updateCdnDomainSsl"
token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"
requestBody := []byte(`{
"domainGrnId": "grn:test:multi-cdn:001:domain/01234565d940e553de8e",
"certGrnId": "grn:test:multi-cdn:001:certificate/1a2b3c4d5e6f7890",
"originProtocol": "https"
}`)
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(requestBody))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", "application/json")
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))
}
输出示例¶
5. 错误码¶
| HTTP 状态码 / 业务提示 | 描述 |
|---|---|
| 200 | 成功 |
| 401 | 未鉴权或 Token 无效 |
| 403 | 无权限 |
| 域名ID不能为空 | 未传 domainGrnId |
| 源站协议不能为空 | 未传 originProtocol |
| OriginProtocol param error: | originProtocol 不是 http、https、follow。原文会在冒号后拼接实际入参 |
| 查询域名ssl失败:证书服务正在维护中 | 证书服务查询失败 |