Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(framework:skip) Restore usage of system certificates by gRPC client #4543

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/py/flwr/common/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,17 @@ def try_obtain_root_certificates(
root_certificates = None
else:
# Load the certificates if provided, or load the system certificates
if not isfile(root_cert_path):
if root_cert_path is None:
log(
WARN,
"Both `--insecure` and `--root-certificates` were not set. "
"Using system certificates.",
)
root_certificates = None
elif not isfile(root_cert_path):
sys.exit("Path argument `--root-certificates` does not point to a file.")
root_certificates = Path(root_cert_path).read_bytes()
else:
root_certificates = Path(root_cert_path).read_bytes()
log(
DEBUG,
"Starting secure HTTPS channel to %s "
Expand Down
5 changes: 4 additions & 1 deletion src/py/flwr/common/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def create_channel(
channel = grpc.insecure_channel(server_address, options=channel_options)
log(DEBUG, "Opened insecure gRPC connection (no certificates were passed)")
else:
ssl_channel_credentials = grpc.ssl_channel_credentials(root_certificates)
try:
ssl_channel_credentials = grpc.ssl_channel_credentials(root_certificates)
except Exception as e:
raise ValueError(f"Failed to create SSL channel credentials: {e}") from e
channel = grpc.secure_channel(
server_address, ssl_channel_credentials, options=channel_options
)
Expand Down