File tree Expand file tree Collapse file tree 4 files changed +12
-9
lines changed Expand file tree Collapse file tree 4 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -408,7 +408,7 @@ def client_cert_callback():
408408 return crypto .dump_privatekey (crypto .FILETYPE_PEM , pkey )
409409
410410def check_use_client_cert ():
411- """Returns the effective value of use_client_cert to be used.
411+ """Returns whether the client certificate should to be used for mTLS .
412412
413413 Returns:
414414 str:
@@ -429,8 +429,9 @@ def check_use_client_cert():
429429 cert_path = os .getenv ("GOOGLE_API_CERTIFICATE_CONFIG" )
430430 if cert_path :
431431 with open (cert_path , "r" ) as f :
432- content = f .read ()
433- if "workload" in content :
432+ content = json .load (f )
433+ print ("content: " , content )
434+ if "workload" in str (content ):
434435 return "true"
435436 return "false"
436437 else :
Original file line number Diff line number Diff line change @@ -241,6 +241,8 @@ def my_client_cert_callback():
241241 Raises:
242242 google.auth.exceptions.MutualTLSChannelError: If mutual TLS channel
243243 creation failed for any reason.
244+ google.auth.exceptions.ValueError: If invalid value is
245+ set for `GOOGLE_API_USE_CLIENT_CERTIFICATE`, i.e. not "true" or "false".
244246 """
245247 # Create the metadata plugin for inserting the authorization header.
246248 metadata_plugin = AuthMetadataPlugin (credentials , request )
@@ -256,7 +258,7 @@ def my_client_cert_callback():
256258
257259 # If SSL credentials are not explicitly set, try client_cert_callback and ADC.
258260 if not ssl_credentials :
259- use_client_cert = _mtls_helper .check_use_client_cert ()
261+ use_client_cert = _mtls_helper .check_use_client_cert ()
260262 if use_client_cert == "true" and client_cert_callback :
261263 # Use the callback if provided.
262264 cert , key = client_cert_callback ()
@@ -293,7 +295,7 @@ class SslCredentials:
293295 """
294296
295297 def __init__ (self ):
296- use_client_cert = _mtls_helper .check_use_client_cert ()
298+ use_client_cert = _mtls_helper .check_use_client_cert ()
297299 if use_client_cert != "true" :
298300 self ._is_mtls = False
299301 else :
Original file line number Diff line number Diff line change @@ -444,8 +444,8 @@ def configure_mtls_channel(self, client_cert_callback=None):
444444 google.auth.exceptions.MutualTLSChannelError: If mutual TLS channel
445445 creation failed for any reason.
446446 """
447- use_client_cert = _mtls_helper .check_use_client_cert ()
448- if use_client_cert != "true" :
447+ use_client_cert = _mtls_helper .check_use_client_cert ()
448+ if use_client_cert != "true" :
449449 self ._is_mtls = False
450450 return
451451 try :
Original file line number Diff line number Diff line change @@ -335,8 +335,8 @@ def configure_mtls_channel(self, client_cert_callback=None):
335335 google.auth.exceptions.MutualTLSChannelError: If mutual TLS channel
336336 creation failed for any reason.
337337 """
338- use_client_cert = _mtls_helper .check_use_client_cert ()
339- if use_client_cert != "true" :
338+ use_client_cert = _mtls_helper .check_use_client_cert ()
339+ if use_client_cert != "true" :
340340 return False
341341 try :
342342 import OpenSSL
You can’t perform that action at this time.
0 commit comments