Skip to content

Commit 1a7d126

Browse files
Simplify _create_experimental_host_transport
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent c7c0623 commit 1a7d126

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

google/cloud/spanner_v1/_helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ def _create_experimental_host_transport(
841841
elif ca_certificate:
842842
with open(ca_certificate, "rb") as f:
843843
ca_cert = f.read()
844-
if client_certificate is not None and client_key is not None:
844+
if client_certificate and client_key:
845845
with open(client_certificate, "rb") as f:
846846
client_cert = f.read()
847847
with open(client_key, "rb") as f:
@@ -851,12 +851,12 @@ def _create_experimental_host_transport(
851851
private_key=private_key,
852852
certificate_chain=client_cert,
853853
)
854-
elif client_certificate is None and client_key is None:
855-
ssl_creds = grpc.ssl_channel_credentials(root_certificates=ca_cert)
856-
else:
854+
elif client_certificate or client_key:
857855
raise ValueError(
858856
"Both client_certificate and client_key must be provided for mTLS connection"
859857
)
858+
else:
859+
ssl_creds = grpc.ssl_channel_credentials(root_certificates=ca_cert)
860860
channel = grpc.secure_channel(experimental_host, ssl_creds)
861861
else:
862862
raise ValueError(

0 commit comments

Comments
 (0)