diff --git a/Dockerfile b/Dockerfile index 67f026d03..fa8c5bd22 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Base image -ARG BASE_IMG=python:3.9-slim +ARG BASE_IMG=python:3.10-slim FROM $BASE_IMG # Requirements (use MNIST Keras as default) diff --git a/docker-compose.yaml b/docker-compose.yaml index c8d3aff15..aa4550c25 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -68,7 +68,7 @@ services: build: context: . args: - BASE_IMG: ${BASE_IMG:-python:3.9-slim} + BASE_IMG: ${BASE_IMG:-python:3.10-slim} working_dir: /app volumes: - ${HOST_REPO_DIR:-.}/fedn:/app/fedn @@ -89,7 +89,7 @@ services: build: context: . args: - BASE_IMG: ${BASE_IMG:-python:3.9-slim} + BASE_IMG: ${BASE_IMG:-python:3.10-slim} working_dir: /app volumes: - ${HOST_REPO_DIR:-.}/fedn:/app/fedn @@ -110,7 +110,7 @@ services: build: context: . args: - BASE_IMG: ${BASE_IMG:-python:3.9-slim} + BASE_IMG: ${BASE_IMG:-python:3.10-slim} working_dir: /app volumes: - ${HOST_REPO_DIR:-.}/fedn:/app/fedn @@ -127,7 +127,7 @@ services: build: context: . args: - BASE_IMG: ${BASE_IMG:-python:3.9-slim} + BASE_IMG: ${BASE_IMG:-python:3.10-slim} working_dir: /app volumes: - ${HOST_REPO_DIR:-.}/fedn:/app/fedn diff --git a/docs/conf.py b/docs/conf.py index 963080333..bd2032b0e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,7 +12,7 @@ author = 'Scaleout Systems AB' # The full version, including alpha/beta/rc tags -release = '0.4.1' +release = '0.6.0' # Add any Sphinx extension module names here, as strings extensions = [ diff --git a/fedn/fedn/network/api/client.py b/fedn/fedn/network/api/client.py index 0e0a48a52..58fc27304 100644 --- a/fedn/fedn/network/api/client.py +++ b/fedn/fedn/network/api/client.py @@ -1,5 +1,3 @@ -import uuid - import requests __all__ = ['APIClient'] @@ -137,9 +135,6 @@ def start_session(self, session_id=None, round_timeout=180, rounds=5, round_buff :return: A dict with success or failure message and session config. :rtype: dict """ - # If session id is None, generate a random session id. - if session_id is None: - session_id = str(uuid.uuid4()) response = requests.post(self._get_url('start_session'), json={ 'session_id': session_id, 'round_timeout': round_timeout, diff --git a/fedn/fedn/network/api/interface.py b/fedn/fedn/network/api/interface.py index 0821ed176..e56462493 100644 --- a/fedn/fedn/network/api/interface.py +++ b/fedn/fedn/network/api/interface.py @@ -2,6 +2,7 @@ import copy import os import threading +import uuid from io import BytesIO from flask import jsonify, send_from_directory @@ -863,7 +864,7 @@ def start_session( # Setup session config session_config = { - "session_id": session_id, + "session_id": session_id if session_id else str(uuid.uuid4()), "round_timeout": round_timeout, "buffer_size": round_buffer_size, "model_id": model_id, diff --git a/fedn/fedn/network/clients/client.py b/fedn/fedn/network/clients/client.py index 27e317791..71fca04ff 100644 --- a/fedn/fedn/network/clients/client.py +++ b/fedn/fedn/network/clients/client.py @@ -4,7 +4,7 @@ import os import queue import re -import ssl +import socket import sys import tempfile import threading @@ -15,7 +15,9 @@ from io import BytesIO import grpc +from cryptography.hazmat.primitives.serialization import Encoding from google.protobuf.json_format import MessageToJson +from OpenSSL import SSL import fedn.common.net.grpc.fedn_pb2 as fedn import fedn.common.net.grpc.fedn_pb2_grpc as rpc @@ -149,6 +151,20 @@ def _add_grpc_metadata(self, key, value): # Set metadata using tuple concatenation self.metadata += ((key, value),) + def _get_ssl_certificate(self, domain, port=443): + context = SSL.Context(SSL.SSLv23_METHOD) + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((domain, port)) + ssl_sock = SSL.Connection(context, sock) + ssl_sock.set_tlsext_host_name(domain.encode()) + ssl_sock.set_connect_state() + ssl_sock.do_handshake() + cert = ssl_sock.get_peer_certificate() + ssl_sock.close() + sock.close() + cert = cert.to_cryptography().public_bytes(Encoding.PEM).decode() + return cert + def _connect(self, client_config): """Connect to assigned combiner. @@ -186,7 +202,7 @@ def _connect(self, client_config): elif self.config['secure']: secure = True logger.info("Using CA certificate for GRPC channel.") - cert = ssl.get_server_certificate((host, port)) + cert = self._get_ssl_certificate(host, port=port) credentials = grpc.ssl_channel_credentials(cert.encode('utf-8')) if self.config['token']: diff --git a/fedn/setup.py b/fedn/setup.py index 1dbdb951f..62888ce09 100644 --- a/fedn/setup.py +++ b/fedn/setup.py @@ -2,7 +2,7 @@ setup( name='fedn', - version='0.5.0', + version='0.6.0', description="""Scaleout Federated Learning""", author='Scaleout Systems AB', author_email='contact@scaleoutsystems.com',