When you use the V2.0 SDK for development, HTTPS is the default protocol for accessing Alibaba Cloud services. You can use the protocol parameter of the Config class in the alibabacloud_tea_openapi.models library to select the communication protocol. Supported values are HTTP and HTTPS. To ensure secure data transmission, we recommend that you always use the HTTPS protocol. In addition, when you configure HTTPS, you can specify a minimum TLS version to improve security, meet compliance requirements, and enhance compatibility.
By default, Alibaba Cloud SDK V2.0 for Python supports the following TLS versions: TLSv1, TLSv1.1, TLSv1.2, and TLSv1.3.
Sample code:
from alibabacloud_tea_openapi.models import Config
from Tea.core import TLSVersion
config = Config(
protocol='HTTPS', # Send requests over HTTPS.
tls_min_version=str(TLSVersion.TLSv1_2) # Specify the TLS version.
)
When you make requests using the HTTPS protocol, the SDK enables SSL/TLS certificate validation by default. If your code environment does not have the required certificates, certificate validation may fail. You can use the ignoreSSL parameter of the RuntimeOptions class from the alibabacloud_tea_util.models library to disable SSL/TLS certificate validation. For example, in a test environment, you can set ignoreSSL to True to ignore certificate validation.
Enable SSL/TLS certificate validation in production environments.
Sample code:
from alibabacloud_tea_util.models import RuntimeOptions
# Temporarily skip certificate verification.
runtimeOptions = RuntimeOptions(
ignore_ssl=True
)