Skip to content

Commit f196bed

Browse files
author
Ubuntu
committed
remote attestation for openfl participants
Signed-off-by: Ubuntu <azureuser@ofl-dev-vm-ad-anshumi1.qnxiewjiflyubbpcwut13wv1wh.cx.internal.cloudapp.net>
1 parent 2692150 commit f196bed

File tree

8 files changed

+671
-12
lines changed

8 files changed

+671
-12
lines changed

openfl-docker/gramine_app/fx.manifest.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,5 @@ sgx.allowed_files = [
7171
"file:{{ workspace_root }}/plan/cols.yaml",
7272
"file:{{ workspace_root }}/plan/data.yaml",
7373
"file:{{ workspace_root }}/plan/plan.yaml",
74+
"file:{{ workspace_root }}/attestation",
7475
]

openfl-workspace/workspace/plan/defaults/network.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ settings:
44
agg_port : auto
55
hash_salt : auto
66
use_tls : True
7+
enable_remote_attestation : False
78
client_reconnect_interval : 5
89
require_client_auth : True
910
cert_folder : cert

openfl/interface/aggregator.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from openfl.federated import Plan
3333
from openfl.interface.cli_helper import CERT_DIR
3434
from openfl.utilities import click_types
35+
from openfl.utilities.attestation import attestation_utils as attestation_utils
3536
from openfl.utilities.path_check import is_directory_traversal
3637
from openfl.utilities.utils import getfqdn_env
3738

@@ -91,6 +92,28 @@ def start_(plan, authorized_cols, task_group):
9192
parsed_plan.config["assigner"]["settings"]["selected_task_group"] = task_group
9293
logger.info(f"Setting aggregator to assign: {task_group} task_group")
9394

95+
# Check if remote attestation is enabled in the plan configuration
96+
if "network" in parsed_plan.config and "settings" in parsed_plan.config["network"]:
97+
if parsed_plan.config["network"]["settings"].get("enable_remote_attestation", False):
98+
# Fetch remote attestation environment variables
99+
attestation_env = attestation_utils.fetch_attestation_env_vars()
100+
if attestation_env is not None:
101+
attestation_manager = attestation_utils.AttestationManager(
102+
"aggregator",
103+
attestation_env["ATTESTATION_REPORT_PATH"],
104+
attestation_env["ITA_API_KEY"],
105+
attestation_env["AVS_URL"],
106+
)
107+
# Generate and store the attestation report
108+
attestation_manager.get_attested_identity()
109+
logger.info("Remote attestation report fetched successfully.")
110+
else:
111+
logger.error("Failed to fetch remote attestation environment variables.")
112+
else:
113+
logger.info(
114+
"Remote attestation is not enabled. Skipping attestation report generation."
115+
)
116+
94117
logger.info("🧿 Starting the Aggregator Service.")
95118

96119
parsed_plan.get_server().serve()

openfl/interface/collaborator.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from openfl.cryptography.participant import generate_csr
2424
from openfl.federated import Plan
2525
from openfl.interface.cli_helper import CERT_DIR
26+
from openfl.utilities.attestation import attestation_utils as attestation_utils
2627
from openfl.utilities.path_check import is_directory_traversal
2728
from openfl.utilities.utils import rmtree
2829

@@ -77,7 +78,27 @@ def start_(plan, collaborator_name, data_config):
7778

7879
# TODO: Need to restructure data loader config file loader
7980
logger.info(f"Data paths: {plan_obj.cols_data_paths}")
80-
echo(f"Data = {plan_obj.cols_data_paths}")
81+
# this check is added to avoid mock objects failing
82+
if isinstance(plan_obj, Plan):
83+
if "network" in plan_obj.config and "settings" in plan_obj.config["network"]:
84+
if plan_obj.config["network"]["settings"].get("enable_remote_attestation", False):
85+
# Fetch remote attestation environment variables
86+
attestation_env = attestation_utils.fetch_attestation_env_vars()
87+
if attestation_env is not None:
88+
attestation_manager = attestation_utils.AttestationManager(
89+
collaborator_name,
90+
attestation_env["ATTESTATION_REPORT_PATH"],
91+
attestation_env["ITA_API_KEY"],
92+
attestation_env["AVS_URL"],
93+
)
94+
# Generate and store the attestation report
95+
attestation_manager.get_attested_identity()
96+
logger.info("Remote attestation report stored successfully.")
97+
else:
98+
logger.error("Remote attestation environment variables not set.")
99+
else:
100+
logger.info("Remote attestation is not enabled in the plan configuration.")
101+
81102
logger.info("🧿 Starting a Collaborator Service.")
82103

83104
collaborator = plan_obj.get_collaborator(collaborator_name)

openfl/utilities/attestation/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)