This topic describes how to configure an HTTPS request to call an API operation.
Configure an HTTPS request
By default, Alibaba Cloud Darabonba SDK for Python use HTTP to call an API operation. You can change the protocol to HTTPS.
from aliyunsdkecs.request.v20140526.DescribeInstancesRequest import DescribeInstancesRequest
from aliyunsdkcore.client import AcsClient
# Use the default credential provider chain to initialize the client. For more information, see the "Instantiate a client and configure a credential" topic in the SDK for Python V1.0 documentation.
client = AcsClient(
region_id='<region_id>', # The region ID.
)
request = DescribeInstancesRequest()
request.set_protocol_type('https') # Set the protocol to HTTPS.
client.do_action_with_exception(request) Disable certificate verification
Important
By default, SSL or Transport Layer Security (TLS) certificate verification is enabled in the SDK. The certificate is verified when HTTPS is used to call API operations. If no certificate is installed in your code environment, the certificate verification fails.
To ensure communication security in the production environment, we recommend that you enable certificate verification. If you want to disable certificate verification in the test environment, set the
verifyparameter to False.
from aliyunsdkcore.client import AcsClient
# Use the default credential provider chain to initialize the client. For more information, see the "Instantiate a client and configure a credential" topic in the SDK for Python V1.0 documentation.
client = AcsClient(
region_id='<region_id>', # The region ID.
verify=False # Disable SSL certificate verification.
)Specify a CA certificate
from aliyunsdkcore.client import AcsClient
# Use the default credential provider chain to initialize the client. For more information, see the "Instantiate a client and configure a credential" topic in the SDK for Python V1.0 documentation.
client = AcsClient(
region_id='<region_id>', # The region ID.
verify='./cacert.pem' # The path of the certificate authority (CA) certificate.
)