Help Center/ Content Delivery Network/ API Reference/ API/ Domain Name Configuration/ Configuring a Certificate for a Batch of Domain Names
Updated on 2025-07-24 GMT+08:00

Configuring a Certificate for a Batch of Domain Names

Function

Configure a certificate for multiple acceleration domain names. If an HTTPS certificate has been configured for a domain name, the new certificate will overwrite the original certificate.

  • A single tenant can call this API 20 times per minute.

Calling Method

For details, see Calling APIs.

URI

PUT /v1.0/cdn/domains/config-https-info

Table 1 Query Parameters

Parameter

Mandatory

Type

Description

enterprise_project_id

No

String

Definition

Enterprise project ID. Obtain the enterprise project ID by calling the ListEnterpriseProject API of EPS.

Constraints

This parameter indicates the ID of the enterprise project to which the resource to be queried belongs. It is valid only when the enterprise project function is enabled. The value all indicates all projects.

Range

N/A

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token, which can be obtained by calling the IAM API (value of X-Subject-Token in the response header).

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

https

No

UpdateDomainMultiCertificatesRequestBodyContent object

Definition

HTTPS certificate settings. After the certificate is configured, clients can access CDN PoPs using HTTPS.

Constraints

N/A

Table 4 UpdateDomainMultiCertificatesRequestBodyContent

Parameter

Mandatory

Type

Description

domain_name

Yes

String

Definition

Domain names for which the HTTPS certificate needs to be configured.

Constraints

  • Separate domain names by commas (,).

  • Add up to 50 domain names.

Range

N/A

Default Value

N/A

https_switch

Yes

Integer

Definition

Certificate status.

Constraints

When https_switch is set to 1, the certificate must be specified.

Range

  • 0: disabled.

  • 1: enabled.

Default Value

N/A

access_origin_way

No

Integer

Definition

Origin protocol.

Constraints

N/A

Range

  • 1: same as user.

  • 2: HTTP.

  • 3: HTTPS.

Default Value

2

force_redirect_https

No

Integer

Definition

Whether to enable force redirect to HTTPS to force clients to use HTTPS to access CDN PoPs.

NOTE:
This parameter is about to go offline. You are advised to use force_redirect_config.

Constraints

N/A

Range

  • 0: disabled.

  • 1: enabled.

Default Value

0

force_redirect_config

No

ForceRedirect object

Definition

This parameter is used to force clients to use HTTPS when accessing CDN PoPs.

Constraints

N/A

http2

No

Integer

Definition

Whether to enable HTTP/2 to allow clients to use HTTP/2 when accessing CDN PoPs.

Constraints

N/A

Range

  • 0: disabled.

  • 1: enabled.

Default Value

0

cert_name

No

String

Definition

Certificate name.

Constraints

This parameter is mandatory when https_switch is set to 1.

Range

3 to 64 characters.

Default Value

N/A

certificate

No

String

Definition

SSL certificate content.

Constraints

  • Only the PEM format is supported.

  • This parameter is optional if a certificate is not required.

  • This parameter is mandatory when a certificate is configured for the first time.

  • A complete certificate chain is required.

Range

The certificate chain cannot exceed 20 KB.

Default Value

N/A

private_key

No

String

Definition

Private key of the SSL certificate.

Constraints

  • Only the PEM format is supported.

  • This parameter is optional if a certificate is not required.

  • This parameter is mandatory when a certificate is configured for the first time.

Range

N/A

Default Value

N/A

certificate_type

No

Integer

Definition

Certificate type.

Constraints

N/A

Range

  • 0: your certificate.

  • 2: SSL Certificate Manager (SCM) certificate.

Default Value

0

scm_certificate_id

No

String

Definition

SCM certificate ID, which can be obtained using the API of Cloud Certificate Manager (CCM) for listing certificates.

Constraints

Mandatory when an SCM certificate is configured.

Range

N/A

Default Value

N/A

Table 5 ForceRedirect

Parameter

Mandatory

Type

Description

switch

Yes

Integer

Definition

Whether to enable force redirect to force clients to use HTTPS or HTTP to access CDN PoPs.

Constraints

N/A

Range

  • 1: enabled.

  • 0: disabled.

Default Value

N/A

redirect_type

Yes

String

Definition

Protocol to which requests are forcibly redirected.

Constraints

If force redirect to HTTPS is enabled, an HTTPS certificate must be configured. Otherwise, the access will fail.

Range

  • http: force redirect to HTTP.

  • https: force redirect to HTTPS.

Default Value

N/A

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

https

UpdateDomainMultiCertificatesResponseBodyContent object

HTTPS settings.

status

String

Execution result. The value can be success or fail.

result

Array of result objects

Details.

Table 7 UpdateDomainMultiCertificatesResponseBodyContent

Parameter

Type

Description

domain_name

String

Domain name list.

https_switch

Integer

HTTPS status. Possible values: 0 (disabled) and 1 (enabled). If you set this parameter to 1, a certificate must be configured.

access_origin_way

Integer

Origin protocol. Possible values: 1 (same as user requests), 2 (HTTP, default value), and 3 (HTTPS, only on Huawei PoPs).

force_redirect_https

Integer

Force HTTPS status. Possible values: 0 (disabled) and 1 (enabled).

force_redirect_config

ForceRedirect object

Definition

This parameter is used to force clients to use HTTPS when accessing CDN PoPs.

Constraints

N/A

http2

Integer

HTTP/2 status. Possible values: 0 (disabled) and 1 (enabled).

cert_name

String

Certificate name.

certificate

String

Certificate content.

certificate_type

Integer

Certificate type. Value: 0 (your own certificate).

expiration_time

Long

Certificate expiration time.

Table 8 ForceRedirect

Parameter

Type

Description

switch

Integer

Definition

Whether to enable force redirect to force clients to use HTTPS or HTTP to access CDN PoPs.

Constraints

N/A

Range

  • 1: enabled.

  • 0: disabled.

Default Value

N/A

redirect_type

String

Definition

Protocol to which requests are forcibly redirected.

Constraints

If force redirect to HTTPS is enabled, an HTTPS certificate must be configured. Otherwise, the access will fail.

Range

  • http: force redirect to HTTP.

  • https: force redirect to HTTPS.

Default Value

N/A

Table 9 result

Parameter

Type

Description

domain_name

String

Domain name.

status

String

Execution result. The value can be success or fail.

reason

String

Failure cause.

Example Requests

{
  "https" : {
    "domain_name" : "example1.com",
    "access_origin_way" : 2,
    "http2" : 0,
    "certificate_type" : 0,
    "force_redirect_config" : {
      "redirect_type" : "https",
      "switch" : 1
    },
    "https_switch" : 1,
    "cert_name" : "cdn_test_cert",
    "certificate" : "-----BEGIN CERTIFICATE----------END CERTIFICATE-----",
    "private_key" : "-----BEGIN RSA PRIVATE KEY---------END RSA PRIVATE KEY-----"
  }
}

Example Responses

Status code: 200

OK

{
  "https" : {
    "domain_name" : "example1.com",
    "https_switch" : 1,
    "access_origin_way" : 2,
    "force_redirect_https" : 1,
    "force_redirect_config" : {
      "redirect_type" : "https",
      "switch" : 1
    },
    "http2" : 0,
    "expiration_time" : 1925791912000,
    "cert_name" : "cdn_test_cert",
    "certificate" : "-----BEGIN CERTIFICATE----------END CERTIFICATE-----",
    "certificate_type" : 0
  }
}

SDK Sample Code

The SDK sample code is as follows.

 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
56
57
58
59
60
61
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.cdn.v2.region.CdnRegion;
import com.huaweicloud.sdk.cdn.v2.*;
import com.huaweicloud.sdk.cdn.v2.model.*;


public class UpdateDomainMultiCertificatesSolution {

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

        CdnClient client = CdnClient.newBuilder()
                .withCredential(auth)
                .withRegion(CdnRegion.valueOf("<YOUR REGION>"))
                .build();
        UpdateDomainMultiCertificatesRequest request = new UpdateDomainMultiCertificatesRequest();
        UpdateDomainMultiCertificatesRequestBody body = new UpdateDomainMultiCertificatesRequestBody();
        ForceRedirect forceRedirectConfigHttps = new ForceRedirect();
        forceRedirectConfigHttps.withSwitch(1)
            .withRedirectType("https");
        UpdateDomainMultiCertificatesRequestBodyContent httpsbody = new UpdateDomainMultiCertificatesRequestBodyContent();
        httpsbody.withDomainName("example1.com")
            .withHttpsSwitch(1)
            .withAccessOriginWay(2)
            .withForceRedirectConfig(forceRedirectConfigHttps)
            .withHttp2(0)
            .withCertName("cdn_test_cert")
            .withCertificate("-----BEGIN CERTIFICATE----------END CERTIFICATE-----")
            .withPrivateKey("-----BEGIN RSA PRIVATE KEY---------END RSA PRIVATE KEY-----")
            .withCertificateType(0);
        body.withHttps(httpsbody);
        request.withBody(body);
        try {
            UpdateDomainMultiCertificatesResponse response = client.updateDomainMultiCertificates(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());
        }
    }
}
 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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
from huaweicloudsdkcdn.v2.region.cdn_region import CdnRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcdn.v2 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 = CdnClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CdnRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = UpdateDomainMultiCertificatesRequest()
        forceRedirectConfigHttps = ForceRedirect(
            switch=1,
            redirect_type="https"
        )
        httpsbody = UpdateDomainMultiCertificatesRequestBodyContent(
            domain_name="example1.com",
            https_switch=1,
            access_origin_way=2,
            force_redirect_config=forceRedirectConfigHttps,
            http2=0,
            cert_name="cdn_test_cert",
            certificate="-----BEGIN CERTIFICATE----------END CERTIFICATE-----",
            private_key="-----BEGIN RSA PRIVATE KEY---------END RSA PRIVATE KEY-----",
            certificate_type=0
        )
        request.body = UpdateDomainMultiCertificatesRequestBody(
            https=httpsbody
        )
        response = client.update_domain_multi_certificates(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 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
56
57
58
59
60
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
    cdn "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2/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 := cdn.NewCdnClient(
        cdn.CdnClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.UpdateDomainMultiCertificatesRequest{}
	redirectTypeForceRedirectConfig:= "https"
	forceRedirectConfigHttps := &model.ForceRedirect{
		Switch: int32(1),
		RedirectType: &redirectTypeForceRedirectConfig,
	}
	accessOriginWayHttps:= int32(2)
	http2Https:= int32(0)
	certNameHttps:= "cdn_test_cert"
	certificateHttps:= "-----BEGIN CERTIFICATE----------END CERTIFICATE-----"
	privateKeyHttps:= "-----BEGIN RSA PRIVATE KEY---------END RSA PRIVATE KEY-----"
	certificateTypeHttps:= int32(0)
	httpsbody := &model.UpdateDomainMultiCertificatesRequestBodyContent{
		DomainName: "example1.com",
		HttpsSwitch: int32(1),
		AccessOriginWay: &accessOriginWayHttps,
		ForceRedirectConfig: forceRedirectConfigHttps,
		Http2: &http2Https,
		CertName: &certNameHttps,
		Certificate: &certificateHttps,
		PrivateKey: &privateKeyHttps,
		CertificateType: &certificateTypeHttps,
	}
	request.Body = &model.UpdateDomainMultiCertificatesRequestBody{
		Https: httpsbody,
	}
	response, err := client.UpdateDomainMultiCertificates(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

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

200

OK

Error Codes

See Error Codes.