Activating a CA
Function
This API is used to activate a CA.
You can activate a certificate only when it is in the Pending activation status.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
pca:ca:activate
Write
ca *
g:ResourceTag/<tag-key>
- pca:ca:active
-
-
g:EnterpriseProjectId
URI
POST /v1/private-certificate-authorities/{ca_id}/activate
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
ca_id |
Yes |
String |
ID of the subordinate CA you want to activate. Minimum: 36 Maximum: 36 |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
User token. For details, see [Obtaining a User Token] (https://support.huaweicloud.com/intl/en-us/api-iam/iam_30_0001.html). |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
issuer_id |
Yes |
String |
ID of the parent CA. Minimum: 1 Maximum: 64 |
|
path_length |
No |
Integer |
Path length. Minimum: 0 Maximum: 6 |
|
signature_algorithm |
Yes |
String |
Signature hash algorithm. The options are as follows: |
|
validity |
Yes |
Validity object |
Certificate validity. For details, see data structure for the Validity field. |
|
hsm_cluster_info |
No |
HsmClusterInfo object |
HSM cluster information. This method can be used to encrypt CA only for users in the whitelist. For details, see HsmClusterInfo field description. |
|
type |
No |
String |
Type of the CA you want to create: (This parameter is mandatory if a yearly/monthly CA is activated.) |
|
distinguished_name |
No |
DistinguishedName object |
Certificate name. For details, see data structure of the DistinguishedName field. (This parameter is mandatory if a yearly/monthly CA is activated.) |
|
key_algorithm |
No |
String |
Key algorithm. This parameter is mandatory if a yearly/monthly CA is activated. The options are as follows:
|
|
key_usages |
No |
Array of strings |
Key usage. For details, see [4.2.1.3] in RFC 5280 (https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.3) |
|
crl_configuration |
No |
CrlConfiguration object |
Certificate CRL. For details, see data structure of the CrlConfiguration field. |
|
enterprise_project_id |
No |
String |
Enterprise project ID. If the enterprise project function is not enabled, you do not need to set this parameter. If the enterprise project function is enabled, you can set this parameter when querying a resource. If this parameter is not specified, the system searches for the required resource in all the enterprise projects that you have permissions for. In this case, the value of enterprise_project_id is all. The parameter value must meet one of the following requirements: Is all Is 0 Matches the regular expression ^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
type |
Yes |
String |
Validity period type, which is mandatory. The options are as follows: |
|
value |
Yes |
Integer |
The certificate validity period. The value of this parameter varies depending on the value of type: |
|
start_from |
No |
Integer |
Start time. The options are as follows: |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
hsm_project |
Yes |
String |
Project information. For example, cn-north-7 |
|
hsm_cluster_id |
Yes |
String |
HSM cluster identifier. For example, 54d8301b-b859-4c55-a628-21fcf90e609e |
|
hsm_ca_cert |
Yes |
String |
String following base64 of the certificate in PEM format |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
common_name |
Yes |
String |
Common name (CN) of a certificate. The value can contain a maximum of 64 characters, including only letters, digits, spaces, Chinese characters, hyphens (-), underscores (_), periods (.), commas (,), and asterisks (*). Minimum: 1 Maximum: 64 |
|
country |
Yes |
String |
Country code. The value is a string of two characters and can contain only letters. Minimum: 2 Maximum: 2 |
|
state |
Yes |
String |
Name of a province or city. The value can contain a maximum of 128 characters, including only letters, digits, Chinese characters, spaces, hyphens (-), underscores (_), periods (.), and commas (,). Minimum: 1 Maximum: 128 |
|
locality |
Yes |
String |
Region name. The value can contain a maximum of 128 characters, including only letters, digits, Chinese characters, spaces, hyphens (-), underscores (_), periods (.), and commas (,). Minimum: 1 Maximum: 128 |
|
organization |
Yes |
String |
Organization name. The value can contain a maximum of 64 characters, including only letters, digits, Chinese characters, spaces, hyphens (-), underscores (_), periods (.), and commas (,). Minimum: 1 Maximum: 64 |
|
organizational_unit |
Yes |
String |
Organization unit name. The value can contain a maximum of 64 characters, including only letters, digits, Chinese characters, spaces, hyphens (-), underscores (_), periods (.), and commas (,). Minimum: 1 Maximum: 64 |
Response Parameters
Status code: 204
Request succeeded, but no response body returned.
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error message Minimum: 0 Maximum: 1024 |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error message Minimum: 0 Maximum: 1024 |
Status code: 403
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error message Minimum: 0 Maximum: 1024 |
Status code: 404
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error message Minimum: 0 Maximum: 1024 |
Status code: 500
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error message Minimum: 0 Maximum: 1024 |
Example Requests
When you call this API, a token with the permission to use this API is mandatory for the X-Auth-Token field.
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"
}
Example Responses
Status code: 400
Invalid request parameters.
{
"error_code" : "PCA.XXX",
"error_msg" : "XXX"
}
Status code: 401
Token required for the requested page.
{
"error_code" : "PCA.XXX",
"error_msg" : "XXX"
}
Status code: 403
Authentication failed.
{
"error_code" : "PCA.XXX",
"error_msg" : "XXX"
}
Status code: 404
No resources available or found.
{
"error_code" : "PCA.XXX",
"error_msg" : "XXX"
}
Status code: 500
Internal service error.
{
"error_code" : "PCA.XXX",
"error_msg" : "XXX"
}
SDK Sample Code
The SDK sample code is as follows.
Java
When you call this API, a token with the permission to use this API is mandatory for the X-Auth-Token field.
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
When you call this API, a token with the permission to use this API is mandatory for the X-Auth-Token field.
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
When you call this API, a token with the permission to use this API is mandatory for the X-Auth-Token field.
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) } } |
More
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
|
Status Code |
Description |
|---|---|
|
204 |
Request succeeded, but no response body returned. |
|
400 |
Invalid request parameters. |
|
401 |
Token required for the requested page. |
|
403 |
Authentication failed. |
|
404 |
No resources available or found. |
|
500 |
Internal service error. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot