跳转至

申请证书

1. 接口描述

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

requestCertificate 用于向 AWS Certificate Manager 申请免费 SSL 证书,创建后需按所选验证方式完成域名验证。未传 subjectAlternativeNames 时,服务端会默认仅包含 domainName

账号需具备 acdn:CreateCertificate 权限。

Token 获取方式见 密钥鉴权

2. 输入参数

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

参数名称 必选 类型 描述
domainName String 主域名。支持泛域名,如 *.example.com。示例值:*.example.com
keyAlgorithm String 密钥算法。取值:RSA_1024RSA_2048RSA_3072RSA_4096EC_prime256v1EC_secp384r1EC_secp521r1。示例值: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.certificateTransparencyLoggingPreference String 证书透明度日志偏好。取值:ENABLED(启用)、DISABLED(关闭)。示例值:ENABLED
idempotencyToken String 幂等令牌
certificateAuthorityArn String 私有 CA ARN(私有证书时使用)
tags Array 标签列表,元素含 keyvalue

3. 输出参数

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

4. 示例

示例1 申请 DNS 验证证书

输入示例

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

代码调用

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

curl -X POST 'https://{登录域名}/prod-api/acdn/ssl/acdn/requestCertificate' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.xxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
  "domainName": "*.example.com",
  "keyAlgorithm": "RSA_2048",
  "validationMethod": "DNS",
  "options": {
    "certificateTransparencyLoggingPreference": "ENABLED"
  },
  "subjectAlternativeNames": ["demo.com"]
}'
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 RequestCertificateTest {

    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\":{\"certificateTransparencyLoggingPreference\":\"ENABLED\"},"
                + "\"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": {
    "certificateTransparencyLoggingPreference": "ENABLED"
  },
  "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"
}

5. 错误码

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