Alibaba Cloud SDK V2.0 sends all requests over HTTPS by default. You can also set the minimum Transport Layer Security (TLS) version and disable Secure Sockets Layer (SSL)/TLS certificate validation for test environments.
Set the request protocol
Use the protocol parameter of the Config class in alibabacloud_tea_openapi.models to set the communication protocol. Valid values: HTTP, HTTPS.
Always use HTTPS to protect data in transit.
from alibabacloud_tea_openapi.models import Config
config = Config(
protocol='HTTPS', # Send requests over HTTPS.
)Set the minimum TLS version
Use the tls_min_version parameter of the Config class to enforce a minimum TLS version.
Alibaba Cloud SDK V2.0 for Python supports the following TLS versions: TLSv1, TLSv1.1, TLSv1.2, and TLSv1.3.
Get the TLS version value from the TLSVersion enum in the Tea.core module and convert it to a string with str().
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) # Set TLS 1.2 as the minimum version.
)Disable SSL/TLS certificate validation
The SDK validates SSL/TLS certificates by default when you use HTTPS. If your runtime environment lacks the required certificates, validation may fail.
To skip certificate validation, set the ignoreSSL parameter (named ignore_ssl in Python) of the RuntimeOptions class from alibabacloud_tea_util.models to True.
Only disable certificate validation in test environments. Always enable certificate validation in production environments.
from alibabacloud_tea_util.models import RuntimeOptions
# Disable certificate validation for testing only.
runtime_options = RuntimeOptions(
ignore_ssl=True
)