3232global config_path
3333config_path = None
3434
35+ WORKBENCH_CA_CERT_PATH = "/etc/pki/tls/custom-certs/ca-bundle.crt"
36+
3537
3638class Authentication (metaclass = abc .ABCMeta ):
3739 """
@@ -81,7 +83,7 @@ def __init__(
8183 token : str ,
8284 server : str ,
8385 skip_tls : bool = False ,
84- ca_cert_path : str = "/etc/pki/tls/custom-certs/ca-bundle.crt" ,
86+ ca_cert_path : str = None ,
8587 ):
8688 """
8789 Initialize a TokenAuthentication object that requires a value for `token`, the API Token
@@ -91,7 +93,17 @@ def __init__(
9193 self .token = token
9294 self .server = server
9395 self .skip_tls = skip_tls
94- self .ca_cert_path = ca_cert_path
96+ self .ca_cert_path = self ._gen_ca_cert_path (ca_cert_path )
97+
98+ def _gen_ca_cert_path (self , ca_cert_path : str ):
99+ if ca_cert_path is not None :
100+ return ca_cert_path
101+ elif "CF_SDK_CA_CERT_PATH" in os .environ :
102+ return os .environ .get ("CF_SDK_CA_CERT_PATH" )
103+ elif os .path .exists (WORKBENCH_CA_CERT_PATH ):
104+ return WORKBENCH_CA_CERT_PATH
105+ else :
106+ return None
95107
96108 def login (self ) -> str :
97109 """
@@ -106,13 +118,9 @@ def login(self) -> str:
106118 configuration .api_key_prefix ["authorization" ] = "Bearer"
107119 configuration .host = self .server
108120 configuration .api_key ["authorization" ] = self .token
109- ca_path_env = os .environ .get ("CF_SDK_CA_CERT_PATH" , self .ca_cert_path )
110-
111- if self .skip_tls == False :
112- if ca_path_env != self .ca_cert_path :
113- self .ca_cert_path = ca_path_env
114121
115- if self .ca_cert_path == None :
122+ if not self .skip_tls :
123+ if self .ca_cert_path is None :
116124 configuration .ssl_ca_cert = None
117125 elif os .path .isfile (self .ca_cert_path ):
118126 print (
0 commit comments