文档首页/ 云证书与管理服务 CCM/ API参考/ API/ 管理私有证书/ 私有CA管理/ 激活CA - IssueCertificateAuthorityCertificate
更新时间:2025-11-28 GMT+08:00

激活CA - IssueCertificateAuthorityCertificate

功能介绍

激活CA。

只有当证书处于"待激活"状态时,可进行激活操作。

调试

您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。

授权信息

账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。

  • 如果使用角色与策略授权,具体权限要求请参见权限和授权项
  • 如果使用身份策略授权,需具备如下身份策略权限。

    授权项

    访问级别

    资源类型(*为必须)

    条件键

    别名

    依赖的授权项

    pca:ca:activate

    Write

    ca *

    g:ResourceTag/<tag-key>

    • pca:ca:active

    -

    -

    g:EnterpriseProjectId

URI

POST /v1/private-certificate-authorities/{ca_id}/activate

表1 路径参数

参数

是否必选

参数类型

描述

ca_id

String

所要激活的从属CA证书ID。

最小长度:36

最大长度:36

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户token,参见:IAM token获取方法

表3 请求Body参数

参数

是否必选

参数类型

描述

issuer_id

String

父CA证书ID。

最小长度:1

最大长度:64

path_length

Integer

路径长度。

最小值:0

最大值:6

signature_algorithm

String

签名哈希算法,可选值如下:

  • SHA256

  • SHA384

  • SHA512

  • SM3(中国站)

validity

Validity object

证书有效期,详情请参见Validity字段数据结构说明。

hsm_cluster_info

HsmClusterInfo object

加密机集群信息:

  • 白名单内用户才可以选择此方式对ca进行加密

说明:

详情请参见HsmClusterInfo字段数据结构说明。

type

String

创建的CA类型。(如果激活包周期CA,为必填值)

  • ROOT : 根CA

  • SUBORDINATE : 从属CA

distinguished_name

DistinguishedName object

证书名称配置,详情请参见DistinguishedName字段数据结构说明。(如果激活包周期CA,为必填值)

key_algorithm

String

密钥算法(如果激活包周期CA,为必填值),可选值如下:

  • RSA2048 : RSA算法,密钥长度2048位;

  • RSA4096 : RSA算法,密钥长度4096位;

  • EC256 : 椭圆曲线算法(Elliptic Curve Digital Signature Algorithm (ECDSA)),密钥长度256位;

  • EC384 : 椭圆曲线算法(Elliptic Curve Digital Signature Algorithm (ECDSA)),密钥长度384位;

  • SM2 : 国家密码管理局颁发的椭圆曲线算法(签名哈希算法SM3),密钥长度256位。(中国站)

key_usages

Array of strings

密钥用法,具体标准参见RFC 5280中:4.2.1.3节

  • digitalSignature : 数字签名;

  • nonRepudiation : 不可抵赖;

  • keyEncipherment : 密钥用于加密密钥数据;

  • dataEncipherment : 用于加密数据;

  • keyAgreement : 密钥协商;

  • keyCertSign : 签发证书;

  • cRLSign : 签发吊销列表;

  • encipherOnly : 仅用于加密;

  • decipherOnly : 仅用于解密。

说明:

缺省值如下:

  • 根CA证书:默认为**[digitalSignature,keyCertSign,cRLSign]**,忽略用户传入值;

  • 从属CA证书:默认为**[digitalSignature,keyCertSign,cRLSign]**,支持用户自定义。

crl_configuration

CrlConfiguration object

证书CRL配置,详情请参见CrlConfiguration字段数据结构说明。

enterprise_project_id

String

企业多项目ID。用户未开通企业多项目时,不需要输入该字段。 用户开通企业多项目时,查询资源可以输入该字段。 若用户不输入该字段,默认查询租户所有有权限的企业多项目下的资源。 此时“enterprise_project_id”取值为“all”。 若用户输入该字段,取值满足以下任一条件.

取值为“all”

取值为“0”

满足正则匹配:“^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$”

表4 Validity

参数

是否必选

参数类型

描述

type

String

有效期类型,为必填值:

  • YEAR : 年(12个月)

  • MONTH : 月(统一按31天)

  • DAY : 日

  • HOUR : 小时

value

Integer

证书有效期值,与type对应的类型值,换算成年需满足以下规则:

  • 根CA,有效期小于等于30年;

  • 从属CA与私有证书,有效期小于等于20年。

start_from

Integer

起始时间,为可选值:

  • 格式为时间戳(毫秒级),如1645146939688代表2022-02-18 09:15:39;

  • 不早于当前时间5分钟,即start_from > (current_time - 5min)。

表5 HsmClusterInfo

参数

是否必选

参数类型

描述

hsm_project

String

项目信息:

  • 比如 cn-north-7

hsm_cluster_id

String

加密机集群标识符

  • 比如 54d8301b-b859-4c55-a628-21fcf90e609e

hsm_ca_cert

String

pem格式证书base64之后的字符串

  • MXXXXX

表6 DistinguishedName

参数

是否必选

参数类型

描述

common_name

String

证书通用名称(CN),名称只能由"-"、"_"、" "、"."、","、"*"、字母、数字、汉字组成,长度不能超过64位字符。

最小长度:1

最大长度:64

country

String

国家编码,只能由英文组成,长度为2位字符。

最小长度:2

最大长度:2

state

String

省市名称,名称只能由"-"、"_"、" "、"."、","、字母、数字、汉字组成,长度不能超过128位字符。

最小长度:1

最大长度:128

locality

String

地区名称,名称只能由"-"、"_"、" "、"."、","、字母、数字、汉字组成,长度不能超过128位字符。

最小长度:1

最大长度:128

organization

String

组织名称,名称只能由"-"、"_"、" "、"."、","、字母、数字、汉字组成,长度不能超过64位字符。

最小长度:1

最大长度:64

organizational_unit

String

组织单元名称,名称只能由"-"、"_"、" "、"."、","、字母、数字、汉字组成,长度不能超过64位字符。

最小长度:1

最大长度:64

表7 CrlConfiguration

参数

是否必选

参数类型

描述

enabled

Boolean

是否启用CRL发布功能。

  • true

  • false

crl_name

String

吊销列表文件名称。

说明:

若用户不指定,系统将默认采用当前证书的父CA ID。

obs_bucket_name

String

OBS桶名称。

说明:

当需要启用CRL发布功能:

  • 此参数为必填项,且用户必须已创建委托授权,授予PCA服务对OBS的相关权限,具体参见本文档:证书吊销处理>查看是否具有委托权限证书吊销处理>创建委托

  • 指定的OBS桶必须存在,否则将报错。

valid_days

Integer

CRL更新周期,单位为"天"。当启用CRL发布功能,为必填项。

最小值:7

最大值:30

响应参数

状态码:204

请求已成功,无响应body

状态码:400

表8 响应Body参数

参数

参数类型

描述

error_code

String

错误请求返回的错误码。

最小长度:3

最大长度:36

error_msg

String

错误请求返回的错误信息。

最小长度:0

最大长度:1024

状态码:401

表9 响应Body参数

参数

参数类型

描述

error_code

String

错误请求返回的错误码。

最小长度:3

最大长度:36

error_msg

String

错误请求返回的错误信息。

最小长度:0

最大长度:1024

状态码:403

表10 响应Body参数

参数

参数类型

描述

error_code

String

错误请求返回的错误码。

最小长度:3

最大长度:36

error_msg

String

错误请求返回的错误信息。

最小长度:0

最大长度:1024

状态码:404

表11 响应Body参数

参数

参数类型

描述

error_code

String

错误请求返回的错误码。

最小长度:3

最大长度:36

error_msg

String

错误请求返回的错误信息。

最小长度:0

最大长度:1024

状态码:500

表12 响应Body参数

参数

参数类型

描述

error_code

String

错误请求返回的错误码。

最小长度:3

最大长度:36

error_msg

String

错误请求返回的错误信息。

最小长度:0

最大长度:1024

请求示例

激活CA,请求头中的X-Auth-Token字段需要填写token,且该token需要具有本API的访问权限。

POST https://ccm.cn-north-4.myhuaweicloud.com/v1/private-certificate-authorities/4c0e772e-a30c-4029-b929-b7acb04143f7/activate

{
  "signature_algorithm" : "SHA256",
  "validity" : {
    "type" : "YEAR",
    "value" : 1
  },
  "path_length" : 3,
  "issuer_id" : "c718fe5f-d44a-467f-80f1-948348ff4132"
}

响应示例

状态码:400

请求参数有误。

{
  "error_code" : "PCA.XXX",
  "error_msg" : "XXX"
}

状态码:401

被请求的页面需要鉴权。

{
  "error_code" : "PCA.XXX",
  "error_msg" : "XXX"
}

状态码:403

认证失败。

{
  "error_code" : "PCA.XXX",
  "error_msg" : "XXX"
}

状态码:404

资源不存在或资源未找到。

{
  "error_code" : "PCA.XXX",
  "error_msg" : "XXX"
}

状态码:500

服务内部错误。

{
  "error_code" : "PCA.XXX",
  "error_msg" : "XXX"
}

SDK代码示例

SDK代码示例如下。

Java

激活CA,请求头中的X-Auth-Token字段需要填写token,且该token需要具有本API的访问权限。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.GlobalCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.ccm.v1.region.CcmRegion;
import com.huaweicloud.sdk.ccm.v1.*;
import com.huaweicloud.sdk.ccm.v1.model.*;


public class IssueCertificateAuthorityCertificateSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");

        ICredential auth = new GlobalCredentials()
                .withAk(ak)
                .withSk(sk);

        CcmClient client = CcmClient.newBuilder()
                .withCredential(auth)
                .withRegion(CcmRegion.valueOf("<YOUR REGION>"))
                .build();
        IssueCertificateAuthorityCertificateRequest request = new IssueCertificateAuthorityCertificateRequest();
        request.withCaId("{ca_id}");
        IssueCertificateAuthorityCertificateRequestBody body = new IssueCertificateAuthorityCertificateRequestBody();
        Validity validitybody = new Validity();
        validitybody.withType("YEAR")
            .withValue(1);
        body.withValidity(validitybody);
        body.withSignatureAlgorithm("SHA256");
        body.withPathLength(3);
        body.withIssuerId("c718fe5f-d44a-467f-80f1-948348ff4132");
        request.withBody(body);
        try {
            IssueCertificateAuthorityCertificateResponse response = client.issueCertificateAuthorityCertificate(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Python

激活CA,请求头中的X-Auth-Token字段需要填写token,且该token需要具有本API的访问权限。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
from huaweicloudsdkccm.v1.region.ccm_region import CcmRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkccm.v1 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]

    credentials = GlobalCredentials(ak, sk)

    client = CcmClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CcmRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = IssueCertificateAuthorityCertificateRequest()
        request.ca_id = "{ca_id}"
        validitybody = Validity(
            type="YEAR",
            value=1
        )
        request.body = IssueCertificateAuthorityCertificateRequestBody(
            validity=validitybody,
            signature_algorithm="SHA256",
            path_length=3,
            issuer_id="c718fe5f-d44a-467f-80f1-948348ff4132"
        )
        response = client.issue_certificate_authority_certificate(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

激活CA,请求头中的X-Auth-Token字段需要填写token,且该token需要具有本API的访问权限。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
    ccm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ccm/v1"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ccm/v1/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ccm/v1/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")

    auth := global.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := ccm.NewCcmClient(
        ccm.CcmClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.IssueCertificateAuthorityCertificateRequest{}
	request.CaId = "{ca_id}"
	validitybody := &model.Validity{
		Type: "YEAR",
		Value: int32(1),
	}
	pathLengthIssueCertificateAuthorityCertificateRequestBody:= int32(3)
	request.Body = &model.IssueCertificateAuthorityCertificateRequestBody{
		Validity: validitybody,
		SignatureAlgorithm: "SHA256",
		PathLength: &pathLengthIssueCertificateAuthorityCertificateRequestBody,
		IssuerId: "c718fe5f-d44a-467f-80f1-948348ff4132",
	}
	response, err := client.IssueCertificateAuthorityCertificate(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

204

请求已成功,无响应body

400

请求参数有误。

401

被请求的页面需要鉴权。

403

认证失败。

404

资源不存在或资源未找到。

500

服务内部错误。

错误码

请参见错误码