|
18 | 18 | if __name__ == "__main__": |
19 | 19 |
|
20 | 20 | parser = argparse.ArgumentParser(description="Reads parameters from command line.") |
21 | | - |
22 | 21 | parser.add_argument("--client_id", type=int, default="Client Id", help="Number of client") |
23 | 22 | parser.add_argument("--dataset", type=str, default="dt4h_format", help="Dataloader to use") |
24 | 23 | parser.add_argument("--metadata_file", type=str, default="metadata.json", help="Json file with metadata") |
|
38 | 37 | parser.add_argument("--data_path", type=str, default=None, help="Data path") |
39 | 38 | parser.add_argument("--production_mode", type=str, default="True", help="Production mode") |
40 | 39 | parser.add_argument("--certs_path", type=str, default="./", help="Certificates path") |
| 40 | + parser.add_argument("--node_name", type=str, default="./", help="Node name for certificates") |
41 | 41 |
|
42 | 42 | parser.add_argument("--sandbox_path", type=str, default="./", help="Sandbox path to use") |
43 | 43 | parser.add_argument("--experiment", type=json.loads, default={"name": "experiment_1", "log_path": "logs", "debug": "true"}, help="experiment logs") |
|
86 | 86 | # Path(os.path.join(config["certs_path"],"rootCA_cert.pem")).read_bytes(), |
87 | 87 | # Path(os.path.join(config["certs_path"],"rootCA_key.pem")).read_bytes() ) |
88 | 88 |
|
89 | | -# root_cert = Path(os.path.join(config["certs_path"],"rootCA_cert.pem")).read_bytes() |
90 | | -# client_cert = Path(os.path.join(config["certs_path"],"rootCA_cert.pem")).read_bytes() |
91 | | -# client_key = Path(os.path.join(config["certs_path"],"rootCA_key.pem")).read_bytes() |
| 89 | + root_cert = Path(os.path.join(config["certs_path"],"rootCA_cert.pem")).read_bytes() |
| 90 | + client_cert = Path(os.path.join(config["certs_path"],config["node_name"]+"_client_cert.pem")).read_bytes() |
| 91 | + client_key = Path(os.path.join(config["certs_path"],config["node_name"]+"_client_key.pem")).read_bytes() |
92 | 92 |
|
93 | | -# ssl_credentials = grpc.ssl_channel_credentials( |
94 | | -# root_cert, # Certificado raíz del servidor |
95 | | -# client_key, # Clave privada del cliente |
96 | | -# client_cert # Certificado del cliente |
97 | | -# ) |
| 93 | + ssl_credentials = grpc.ssl_channel_credentials( |
| 94 | + root_certificates=root_cert, # Certificado raíz del servidor |
| 95 | + private_key=client_key, # Clave privada del cliente |
| 96 | + certificate_chain=client_cert # Certificado del cliente |
| 97 | + ) |
98 | 98 |
|
99 | 99 | central_ip = os.getenv("FLOWER_CENTRAL_SERVER_IP") |
100 | 100 | central_port = os.getenv("FLOWER_CENTRAL_SERVER_PORT") |
101 | | -# channel = grpc.secure_channel(f"{central_ip}:{central_port}", ssl_credentials) |
| 101 | + channel = grpc.secure_channel(f"{central_ip}:{central_port}", ssl_credentials) |
102 | 102 |
|
103 | 103 | else: |
104 | 104 | data_path = config["data_path"] |
|
141 | 141 | if isinstance(client, fl.client.NumPyClient): |
142 | 142 | fl.client.start_numpy_client( |
143 | 143 | server_address=f"{central_ip}:{central_port}", |
144 | | - # credentials=ssl_credentials, |
145 | | - root_certificates=root_certificate, |
| 144 | + #credentials=ssl_credentials, |
| 145 | + #root_certificates=root_certificate, |
146 | 146 | client=client, |
147 | | - # channel=channel, |
| 147 | + channel=channel, |
148 | 148 | ) |
149 | 149 | else: |
150 | 150 | fl.client.start_client( |
151 | 151 | server_address=f"{central_ip}:{central_port}", |
152 | 152 | # credentials=ssl_credentials, |
153 | | - root_certificates=root_certificate, |
| 153 | + # root_certificates=root_certificate, |
154 | 154 | client=client, |
155 | | - # channel=channel, |
| 155 | + channel=channel, |
156 | 156 | ) |
157 | 157 | break # Si todo salió bien, salimos del bucle |
158 | 158 | except Exception as e: |
|
0 commit comments