mrs83 commited on
Commit
905e1ea
·
1 Parent(s): 1c0aad9

TLS must be enabled by default... (#20)

Browse files

* TLS must be enabled by default (also in development)

blossomtune_gradio/config.py CHANGED
@@ -42,10 +42,13 @@ PROJECT_PATH = os.path.realpath(
42
  # BlossomTune cert - To be distributed to the participants (supernodes).
43
  BLOSSOMTUNE_TLS_CERT_PATH = os.getenv(
44
  "BLOSSOMTUNE_TLS_CERT_PATH",
45
- "/data/certs/server.crt"
46
  if os.path.isdir("/data/certs")
47
- else os.path.join(PROJECT_PATH, "./data/certs/server.crt"),
48
  )
 
 
 
49
 
50
  # Flower Apps
51
  FLOWER_APPS = os.getenv("FLOWER_APPS", ["flower_apps.quickstart_huggingface"])
 
42
  # BlossomTune cert - To be distributed to the participants (supernodes).
43
  BLOSSOMTUNE_TLS_CERT_PATH = os.getenv(
44
  "BLOSSOMTUNE_TLS_CERT_PATH",
45
+ "/data/certs"
46
  if os.path.isdir("/data/certs")
47
+ else os.path.join(PROJECT_PATH, "./data/certs"),
48
  )
49
+ BLOSSOMTUNE_TLS_CA_CERTFILE = os.path.join(BLOSSOMTUNE_TLS_CERT_PATH, "ca.crt")
50
+ BLOSSOMTUNE_TLS_CERTFILE = os.path.join(BLOSSOMTUNE_TLS_CERT_PATH, "server.pem")
51
+ BLOSSOMTUNE_TLS_KEYFILE = os.path.join(BLOSSOMTUNE_TLS_CERT_PATH, "server.key")
52
 
53
  # Flower Apps
54
  FLOWER_APPS = os.getenv("FLOWER_APPS", ["flower_apps.quickstart_huggingface"])
blossomtune_gradio/federation.py CHANGED
@@ -103,7 +103,7 @@ def check_participant_status(pid_to_check: str, email: str, activation_code: str
103
  num_partitions=num_partitions,
104
  )
105
  # The user is fully approved. Return success and the cert path.
106
- return (True, connection_string, cfg.BLOSSOMTUNE_TLS_CERT_PATH)
107
  elif request.status == "pending":
108
  return (False, settings.get_text("status_pending_md"), None)
109
  else: # Denied
 
103
  num_partitions=num_partitions,
104
  )
105
  # The user is fully approved. Return success and the cert path.
106
+ return (True, connection_string, cfg.BLOSSOMTUNE_TLS_CA_CERTFILE)
107
  elif request.status == "pending":
108
  return (False, settings.get_text("status_pending_md"), None)
109
  else: # Denied
blossomtune_gradio/processing.py CHANGED
@@ -46,8 +46,15 @@ def start_superlink():
46
  if process_store["superlink"] and process_store["superlink"].poll() is None:
47
  return False, "Superlink process is already running."
48
 
49
- # The command needs to be adapted for TLS if it's not insecure
50
- command = [shutil.which("flower-superlink"), "--insecure"] # Placeholder
 
 
 
 
 
 
 
51
  threading.Thread(
52
  target=run_process, args=(command, "superlink"), daemon=True
53
  ).start()
@@ -97,7 +104,7 @@ def start_runner(
97
  runner_app_path,
98
  "local-deployment",
99
  "--federation-config",
100
- f'address="{cfg.SUPERLINK_HOST}:{cfg.SUPERLINK_CONTROL_API_PORT}" root-certificates="{cfg.BLOSSOMTUNE_TLS_CERT_PATH}"',
101
  "--stream",
102
  ]
103
  threading.Thread(target=run_process, args=(command, "runner"), daemon=True).start()
 
46
  if process_store["superlink"] and process_store["superlink"].poll() is None:
47
  return False, "Superlink process is already running."
48
 
49
+ command = [
50
+ shutil.which("flower-superlink"),
51
+ "--ssl-ca-certfile",
52
+ cfg.BLOSSOMTUNE_TLS_CA_CERTFILE,
53
+ "--ssl-certfile",
54
+ cfg.BLOSSOMTUNE_TLS_CERTFILE,
55
+ "--ssl-keyfile",
56
+ cfg.BLOSSOMTUNE_TLS_KEYFILE,
57
+ ] # Placeholder
58
  threading.Thread(
59
  target=run_process, args=(command, "superlink"), daemon=True
60
  ).start()
 
104
  runner_app_path,
105
  "local-deployment",
106
  "--federation-config",
107
+ f'address="{cfg.SUPERLINK_HOST}:{cfg.SUPERLINK_CONTROL_API_PORT}" root-certificates="{cfg.BLOSSOMTUNE_TLS_CA_CERTFILE}"',
108
  "--stream",
109
  ]
110
  threading.Thread(target=run_process, args=(command, "runner"), daemon=True).start()
flower_apps/quickstart_huggingface/pyproject.toml CHANGED
@@ -60,4 +60,4 @@ options.backend.client-resources.num-gpus = 0.0 # at most 4 ClientApp will run i
60
  [tool.flwr.federations.local-deployment]
61
  address = "0.0.0.0:9093"
62
  insecure = true
63
- root-certificate = ""
 
60
  [tool.flwr.federations.local-deployment]
61
  address = "0.0.0.0:9093"
62
  insecure = true
63
+ root-certificates = ""
tests/test_processing.py CHANGED
@@ -30,7 +30,8 @@ def test_start_superlink_success(mock_which, mock_thread):
30
  mock_thread.assert_called_once()
31
  call_args = mock_thread.call_args
32
  assert call_args.kwargs["target"] == processing.run_process
33
- assert call_args.kwargs["args"][0] == ["/fake/path/flower-superlink", "--insecure"]
 
34
 
35
 
36
  def test_start_superlink_already_running(mocker):
 
30
  mock_thread.assert_called_once()
31
  call_args = mock_thread.call_args
32
  assert call_args.kwargs["target"] == processing.run_process
33
+ assert call_args.kwargs["args"][0][0] == "/fake/path/flower-superlink"
34
+ assert call_args.kwargs["args"][0][1] == "--ssl-ca-certfile"
35
 
36
 
37
  def test_start_superlink_already_running(mocker):