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
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
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 |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
https |
No |
Definition HTTPS certificate settings. After the certificate is configured, clients can access CDN PoPs using HTTPS. Constraints N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
domain_name |
Yes |
String |
Definition Domain names for which the HTTPS certificate needs to be configured. Constraints
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
Default Value N/A |
access_origin_way |
No |
Integer |
Definition Origin protocol. Constraints N/A Range
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
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
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
Range The certificate chain cannot exceed 20 KB. Default Value N/A |
private_key |
No |
String |
Definition Private key of the SSL certificate. Constraints
Range N/A Default Value N/A |
certificate_type |
No |
Integer |
Definition Certificate type. Constraints N/A Range
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 |
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
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
Default Value N/A |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
https |
HTTPS settings. |
|
status |
String |
Execution result. The value can be success or fail. |
result |
Array of result objects |
Details. |
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. |
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
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
Default Value N/A |
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.
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