跳转至

申请证书

1. 接口描述

接口请求路径:POST /prod-api/acdn/ssl/acdn/requestCertificate

requestCertificate 用于向 AWS Certificate Manager 申请免费 SSL 证书,创建后需按所选验证方式完成域名验证。

需要权限 acdn:distributions:edit,策略 acdn:CreateCertificate

Token 获取方式见 密钥鉴权

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数

参数名称 必选 类型 描述
domainName String 主域名。支持泛域名,如 *.example.com
示例值:*.example.com
keyAlgorithm String 密钥算法,支持以下值:
RSA_2048:RSA 2048
EC_prime256v1:ECDSA P-256
EC_secp384r1:ECDSA P-384
示例值:RSA_2048
validationMethod String 域名验证方式,支持以下值:
DNS:DNS 验证
EMAIL:电子邮件验证
示例值:DNS
subjectAlternativeNames Array of String 附加域名(SAN)列表。未传时默认仅包含 domainName
示例值:["demo.com"]
domainValidationOptions Array 域名验证选项,用于 EMAIL 验证时指定验证邮箱域名
domainValidationOptions[].domainName String 待验证域名
domainValidationOptions[].validationDomain String 验证邮件接收域名
options Object 证书选项
options.export String 是否允许导出私钥,支持以下值:
DISABLED:禁止导出
示例值:DISABLED

3. 示例

示例1 申请 DNS 验证证书

输入示例

{
  "domainName": "*.example.com",
  "keyAlgorithm": "RSA_2048",
  "validationMethod": "DNS",
  "options": {
    "export": "DISABLED"
  },
  "subjectAlternativeNames": ["demo.com"]
}

代码调用

请将 {登录域名}token 替换为实际值。

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 AcdnRequestCertificateTest {

    public static void main(String[] args) throws Exception {
        String url = "https://{登录域名}/prod-api/acdn/ssl/acdn/requestCertificate";
        String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";

        String requestBody = "{"
                + "\"domainName\":\"*.example.com\","
                + "\"keyAlgorithm\":\"RSA_2048\","
                + "\"validationMethod\":\"DNS\","
                + "\"options\":{\"export\":\"DISABLED\"},"
                + "\"subjectAlternativeNames\":[\"demo.com\"]"
                + "}";

        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/acdn/ssl/acdn/requestCertificate"
    token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"

    requestBody := []byte(`{
  "domainName": "*.example.com",
  "keyAlgorithm": "RSA_2048",
  "validationMethod": "DNS",
  "options": {
    "export": "DISABLED"
  },
  "subjectAlternativeNames": ["demo.com"]
}`)

    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))
}

输出示例

{
  "msg": "操作成功",
  "code": 200,
  "data": "arn:aws:acm:us-east-1:654268366154:certificate/53677e7f-c9c1-4bb8-aedc-ff6798a03083"
}

4. 输出参数

参数名称 类型 描述
code Integer 状态码。示例值:200
msg String 提示信息。示例值:操作成功
data String 新申请证书的 ARN,可用于后续查询验证状态或绑定分发
示例值:arn:aws:acm:us-east-1:654268366154:certificate/53677e7f-c9c1-4bb8-aedc-ff6798a03083

5. 错误码

HTTP 状态码 / 业务提示 描述
200 成功
401 未鉴权或 Token 无效
403 无权限
请求失败 AWS 证书申请失败