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

Document how to enable SSL in public API #845

Merged
merged 43 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a6bd93f
Add secure gRPC client implemenation
tanertopal Sep 14, 2021
9f06b9c
Document how to enable SSL in public API
tanertopal Sep 14, 2021
7cbab48
Merge branch 'main' into secure_client
tanertopal Sep 16, 2021
ceb38b5
Merge branch 'main' into secure_app_start
tanertopal Sep 16, 2021
d852355
Merge branch 'main' into secure_client
tanertopal Sep 16, 2021
f264599
Merge branch 'main' into secure_client
tanertopal Nov 14, 2021
4e74432
Merge branch 'main' into secure_client
tanertopal Nov 14, 2021
fd00467
Merge branch 'main' into secure_app_start
tanertopal Nov 15, 2021
f3f75a0
Merge branch 'main' into secure_client
tanertopal Jan 5, 2022
3e309b0
Merge branch 'main' into secure_app_start
tanertopal Jan 5, 2022
c0b425c
Update src/py/flwr/client/app.py
tanertopal Jan 5, 2022
a1a3c38
Update src/py/flwr/client/app.py
tanertopal Jan 5, 2022
410e911
Update src/py/flwr/client/app.py
tanertopal Jan 5, 2022
ea42422
Update src/py/flwr/client/app.py
tanertopal Jan 5, 2022
e0e9c92
Update src/py/flwr/client/grpc_client/connection.py
tanertopal Jan 5, 2022
3fba0f8
Update src/py/flwr/client/grpc_client/connection.py
tanertopal Jan 5, 2022
c4a8afd
Update src/py/flwr/client/grpc_client/connection.py
tanertopal Jan 5, 2022
c3a1db5
Update src/py/flwr/client/app.py
tanertopal Jan 5, 2022
157d83e
Update src/py/flwr/client/app.py
tanertopal Jan 5, 2022
3d849da
Merge branch 'main' into secure_client
tanertopal Jan 5, 2022
fe962df
Fix
tanertopal Jan 5, 2022
717d471
Fix
tanertopal Jan 5, 2022
5b31a46
Fix docs
tanertopal Jan 5, 2022
cf37dde
Fix
tanertopal Jan 5, 2022
adb2f10
fix
tanertopal Jan 5, 2022
034ab70
fix
tanertopal Jan 5, 2022
d4739dc
Update src/py/flwr/client/app.py
tanertopal Jan 5, 2022
b78375b
Update src/py/flwr/client/app.py
tanertopal Jan 5, 2022
9253a6f
Update src/py/flwr/client/app.py
tanertopal Jan 5, 2022
169560b
Update src/py/flwr/client/app.py
tanertopal Jan 5, 2022
fc4e540
Update src/py/flwr/client/app.py
tanertopal Jan 5, 2022
09823bd
Update src/py/flwr/client/grpc_client/connection.py
tanertopal Jan 5, 2022
6067301
Update src/py/flwr/client/grpc_client/connection.py
tanertopal Jan 5, 2022
fe9ee89
Update src/py/flwr/client/grpc_client/connection.py
tanertopal Jan 5, 2022
7ea0867
fix
tanertopal Jan 5, 2022
6fcb82d
Merge branch 'main' into secure_app_start
tanertopal Jan 5, 2022
3097747
Merge branch 'secure_client' into secure_app_start
tanertopal Jan 5, 2022
6f23a9c
Update docs
tanertopal Jan 5, 2022
c587854
Merge branch 'main' into secure_app_start
tanertopal Jan 5, 2022
40d6036
Update grpc_server.py
tanertopal Jan 5, 2022
d2a926e
Update src/py/flwr/server/app.py
danieljanes Jan 5, 2022
22d281b
Update src/py/flwr/server/app.py
danieljanes Jan 5, 2022
8aade22
Update src/py/flwr/server/app.py
danieljanes Jan 6, 2022
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
41 changes: 34 additions & 7 deletions src/py/flwr/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ def start_server( # pylint: disable=too-many-arguments
strategy: Optional[Strategy] = None,
grpc_max_message_length: int = GRPC_MAX_MESSAGE_LENGTH,
force_final_distributed_eval: bool = False,
ssl_files: Optional[Tuple[bytes, bytes, bytes]] = None,
) -> History:
"""Start a Flower server using the gRPC transport layer.

Arguments:
Arguments
---------
server_address: Optional[str] (default: `"[::]:8080"`). The IPv6
address of the server.
server: Optional[flwr.server.Server] (default: None). An implementation
Expand All @@ -63,9 +65,34 @@ def start_server( # pylint: disable=too-many-arguments
force_final_distributed_eval: bool (default: False).
Forces a distributed evaluation to occur after the last training
epoch when enabled.
ssl_files : Tuple[bytes, bytes, bytes] (default: None)
Tuple containing root certificate, server certificate, and private key to
start a secure SSL/TLS server. The tuple is expected to have three bytes
elements in the following order:

Returns:
* CA certificate.
* server certificate.
* server private key.

Returns
-------
hist: flwr.server.history.History. Object containing metrics from training.

Examples
--------
Starting an insecure server:

>>> start_server()

Starting a SSL/TLS-enabled server:

>>> start_server(
>>> ssl_files=(
>>> Path("/crts/root.pem").read_bytes(),
>>> Path("/crts/localhost.crt").read_bytes(),
>>> Path("/crts/localhost.key").read_bytes()
>>> )
>>> )
"""
initialized_server, initialized_config = _init_defaults(server, config, strategy)

Expand All @@ -74,12 +101,12 @@ def start_server( # pylint: disable=too-many-arguments
client_manager=initialized_server.client_manager(),
server_address=server_address,
max_message_length=grpc_max_message_length,
ssl_files=ssl_files,
)
log(
INFO,
"Flower server running (insecure, %s rounds)",
initialized_config["num_rounds"],
)
num_rounds = initialized_config["num_rounds"]
ssl_status = "enabled" if ssl_files is not None else "disabled"
msg = f"Flower server running ({num_rounds} rounds)\nSSL/TLS is {ssl_status}"
log(INFO, msg)

hist = _fl(
server=initialized_server,
Expand Down
8 changes: 3 additions & 5 deletions src/py/flwr/server/grpc_server/grpc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,15 @@ def start_grpc_server(
max_message_length : int
Maximum message length that the server can send or receive.
Int valued in bytes. -1 means unlimited. (default: GRPC_MAX_MESSAGE_LENGTH)
ssl_files : Tuple[bytes, bytes, bytes]
Tuple containing root certificate, server certificate, and private key to start
a secure SSL/TLS server. The tuple is expected to have three byte string
ssl_files : Tuple[bytes, bytes, bytes] (default: None)
Tuple containing root certificate, server certificate, and private key to
start a secure SSL/TLS server. The tuple is expected to have three bytes
elements in the following order:

* CA certificate.
* server certificate.
* server private key.

(default: None)

Returns
-------
server : grpc.Server
Expand Down