Skip to content

Commit ac46f46

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 89f0c2f commit ac46f46

File tree

7 files changed

+677
-0
lines changed

7 files changed

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

96120
parsed_plan.get_server().serve()

openfl/interface/collaborator.py

Lines changed: 23 additions & 0 deletions
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,6 +78,28 @@ def start_(plan, collaborator_name, data_config):
7778
)
7879

7980
# TODO: Need to restructure data loader config file loader
81+
# print plan object
82+
# check if plan is dict
83+
if isinstance(plan, dict):
84+
# Check if remote attestation is enabled in the plan configuration
85+
if "network" in plan.config and "settings" in plan.config["network"]:
86+
if plan.config["network"]["settings"].get("enable_remote_attestation", False):
87+
# Fetch remote attestation environment variables
88+
attestation_env = attestation_utils.fetch_attestation_env_vars()
89+
if attestation_env is not None:
90+
attestation_manager = attestation_utils.AttestationManager(
91+
collaborator_name,
92+
attestation_env["ATTESTATION_REPORT_PATH"],
93+
attestation_env["ITA_API_KEY"],
94+
attestation_env["AVS_URL"],
95+
)
96+
# Generate and store the attestation report
97+
attestation_manager.get_attested_identity()
98+
logger.info("Remote attestation report stored successfully.")
99+
else:
100+
logger.error("Remote attestation environment variables not set.")
101+
else:
102+
logger.info("Remote attestation is not enabled in the plan configuration.")
80103

81104
echo(f"Data = {plan.cols_data_paths}")
82105
logger.info("🧿 Starting a Collaborator Service.")

openfl/utilities/attestation/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)