Skip to content

Commit 67e8af8

Browse files
authored
Made --no-verify-ssl work for pro tenants as well (#3767)
* Properly ignoring SSL Certificate errors now * Removed unnecessary docstring change
1 parent f7a3e91 commit 67e8af8

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/zenml/cli/login.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ def connect_to_pro_server(
229229
api_key: Optional[str] = None,
230230
refresh: bool = False,
231231
pro_api_url: Optional[str] = None,
232+
verify_ssl: Union[str, bool] = True,
232233
) -> None:
233234
"""Connect the client to a ZenML Pro server.
234235
@@ -238,6 +239,8 @@ def connect_to_pro_server(
238239
api_key: The API key to use to authenticate with the ZenML Pro server.
239240
refresh: Whether to force a new login flow with the ZenML Pro server.
240241
pro_api_url: The URL for the ZenML Pro API.
242+
verify_ssl: Whether to verify the server's TLS certificate. If a string
243+
is passed, it is interpreted as the path to a CA bundle file.
241244
242245
Raises:
243246
ValueError: If incorrect parameters are provided.
@@ -280,7 +283,12 @@ def connect_to_pro_server(
280283
# server to connect to.
281284
if api_key:
282285
if server_url:
283-
connect_to_server(server_url, api_key=api_key, pro_server=True)
286+
connect_to_server(
287+
server_url,
288+
api_key=api_key,
289+
pro_server=True,
290+
verify_ssl=verify_ssl,
291+
)
284292
return
285293
else:
286294
raise ValueError(
@@ -299,6 +307,7 @@ def connect_to_pro_server(
299307
try:
300308
token = web_login(
301309
pro_api_url=pro_api_url,
310+
verify_ssl=verify_ssl,
302311
)
303312
except AuthorizationException as e:
304313
cli_utils.error(f"Authorization error: {e}")
@@ -418,7 +427,9 @@ def connect_to_pro_server(
418427
f"Connecting to ZenML Pro server: {server.name} [{str(server.id)}] "
419428
)
420429

421-
connect_to_server(server.url, api_key=api_key, pro_server=True)
430+
connect_to_server(
431+
server.url, api_key=api_key, pro_server=True, verify_ssl=verify_ssl
432+
)
422433

423434
# Update the stored server info with more accurate data taken from the
424435
# ZenML Pro workspace object.
@@ -555,7 +566,7 @@ def _fail_if_authentication_environment_variables_set() -> None:
555566
not return until the server exits or is stopped with CTRL+C
556567
557568
* `--docker`: start the local ZenML server as a Docker container instead
558-
of a local process
569+
of a local background process.
559570
560571
* `--port`: use a custom TCP port value for the local ZenML server
561572
@@ -775,6 +786,9 @@ def login(
775786
pro_server=server,
776787
refresh=True,
777788
pro_api_url=pro_api_url,
789+
verify_ssl=ssl_ca_cert
790+
if ssl_ca_cert is not None
791+
else not no_verify_ssl,
778792
)
779793
return
780794

@@ -822,6 +836,7 @@ def login(
822836
# Prefer the pro API URL extracted from the server info if
823837
# available
824838
pro_api_url=server_pro_api_url or pro_api_url,
839+
verify_ssl=verify_ssl,
825840
)
826841
else:
827842
connect_to_server(
@@ -837,6 +852,7 @@ def login(
837852
api_key=api_key_value,
838853
refresh=refresh,
839854
pro_api_url=pro_api_url,
855+
verify_ssl=verify_ssl,
840856
)
841857

842858
elif current_non_local_server and not refresh:
@@ -861,6 +877,7 @@ def login(
861877
# Prefer the pro API URL extracted from the server info if
862878
# available
863879
pro_api_url=server_pro_api_url or pro_api_url,
880+
verify_ssl=verify_ssl,
864881
)
865882
else:
866883
cli_utils.declare(
@@ -890,6 +907,7 @@ def login(
890907
connect_to_pro_server(
891908
api_key=api_key_value,
892909
pro_api_url=pro_api_url,
910+
verify_ssl=verify_ssl,
893911
)
894912

895913

0 commit comments

Comments
 (0)