diff --git a/docs/source/advanced_features/request_configuration.rst b/docs/source/advanced_features/request_configuration.rst index 505689a41..5ffdb080f 100644 --- a/docs/source/advanced_features/request_configuration.rst +++ b/docs/source/advanced_features/request_configuration.rst @@ -30,6 +30,9 @@ Note that the default settings can satisfy most use cases. * - allowed_retry_status - | The allowed status for retrying request. | Default: [429, 500, 502, 503, 504] + * - verify + - | Whether to verify the server's TLS certificate. + | Default: True * - timeout - | The number of seconds before the request times out. | Scenario: Enlarge it when under poor network quality. diff --git a/tensorbay/utility/requests.py b/tensorbay/utility/requests.py index 382759e2a..61c36bff8 100644 --- a/tensorbay/utility/requests.py +++ b/tensorbay/utility/requests.py @@ -46,6 +46,7 @@ class Config: allowed_retry_methods: The allowed methods for retrying request. allowed_retry_status: The allowed status for retrying request. If both methods and status are fitted, the retrying strategy will work. + verify: Whether to verify the server's TLS certificate. timeout: Timeout value of the request in seconds. is_internal: Whether the request is from internal. @@ -56,6 +57,7 @@ def __init__(self) -> None: self.max_retries = 3 self.allowed_retry_methods = ["HEAD", "OPTIONS", "POST", "PUT"] self.allowed_retry_status = [429, 500, 502, 503, 504] + self.verify = True self.timeout = 30 self.is_internal = False @@ -144,7 +146,9 @@ def request( # type: ignore[override] """ try: - response = super().request(method, url, *args, **kwargs) + response = super().request( + method, url, *args, verify=config.verify, **kwargs # type: ignore[misc] + ) if response.status_code not in (200, 201): logger.error( "Unexpected status code(%d)!%s", response.status_code, ResponseLogging(response)