激活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
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
ca_id |
是 |
String |
所要激活的从属CA证书ID。 最小长度:36 最大长度:36 |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
X-Auth-Token |
是 |
String |
用户token,参见:IAM token获取方法。 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
issuer_id |
是 |
String |
父CA证书ID。 最小长度:1 最大长度:64 |
|
path_length |
否 |
Integer |
路径长度。 最小值:0 最大值:6 |
|
signature_algorithm |
是 |
String |
签名哈希算法,可选值如下: |
|
validity |
是 |
Validity object |
证书有效期,详情请参见Validity字段数据结构说明。 |
|
hsm_cluster_info |
否 |
HsmClusterInfo object |
加密机集群信息:
说明:
详情请参见HsmClusterInfo字段数据结构说明。 |
|
type |
否 |
String |
创建的CA类型。(如果激活包周期CA,为必填值) |
|
distinguished_name |
否 |
DistinguishedName object |
证书名称配置,详情请参见DistinguishedName字段数据结构说明。(如果激活包周期CA,为必填值) |
|
key_algorithm |
否 |
String |
密钥算法(如果激活包周期CA,为必填值),可选值如下: |
|
key_usages |
否 |
Array of strings |
密钥用法,具体标准参见RFC 5280中:4.2.1.3节。 |
|
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}$” |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
type |
是 |
String |
有效期类型,为必填值: |
|
value |
是 |
Integer |
证书有效期值,与type对应的类型值,换算成年需满足以下规则: |
|
start_from |
否 |
Integer |
起始时间,为可选值: |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
hsm_project |
是 |
String |
项目信息: |
|
hsm_cluster_id |
是 |
String |
加密机集群标识符 |
|
hsm_ca_cert |
是 |
String |
pem格式证书base64之后的字符串 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
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 |
响应参数
状态码:204
请求已成功,无响应body
状态码:400
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
错误请求返回的错误码。 最小长度:3 最大长度:36 |
|
error_msg |
String |
错误请求返回的错误信息。 最小长度:0 最大长度:1024 |
状态码:401
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
错误请求返回的错误码。 最小长度:3 最大长度:36 |
|
error_msg |
String |
错误请求返回的错误信息。 最小长度:0 最大长度:1024 |
状态码:403
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
错误请求返回的错误码。 最小长度:3 最大长度:36 |
|
error_msg |
String |
错误请求返回的错误信息。 最小长度:0 最大长度:1024 |
状态码:404
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
错误请求返回的错误码。 最小长度:3 最大长度:36 |
|
error_msg |
String |
错误请求返回的错误信息。 最小长度:0 最大长度:1024 |
状态码:500
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
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 |
服务内部错误。 |
错误码
请参见错误码。