Skip to content
14 changes: 8 additions & 6 deletions google/api_core/operations_v1/abstract_operations_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# limitations under the License.
#
from collections import OrderedDict
from distutils import util
import os
import re
from typing import Dict, Optional, Sequence, Tuple, Type, Union
Expand Down Expand Up @@ -294,13 +293,16 @@ def __init__(
client_options = client_options_lib.ClientOptions()

# Create SSL credentials for mutual TLS if needed.
use_client_cert = bool(
util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
)

use_client_cert = os.getenv(
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
).lower()
if use_client_cert not in ("true", "false"):
raise ValueError(
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
)
client_cert_source_func = None
is_mtls = False
if use_client_cert:
if use_client_cert == "true":
if client_options.client_cert_source:
is_mtls = True
client_cert_source_func = client_options.client_cert_source
Expand Down