diff --git a/gns3server/schemas/config.py b/gns3server/schemas/config.py index 27a4ca2d..f5155ec3 100644 --- a/gns3server/schemas/config.py +++ b/gns3server/schemas/config.py @@ -146,7 +146,6 @@ class ServerSettings(BaseModel): enable_builtin_templates: bool = True model_config = ConfigDict(validate_assignment=True, str_strip_whitespace=True, use_enum_values=True) - @field_validator("additional_images_paths", mode="before") @classmethod def split_additional_images_paths(cls, v): @@ -154,7 +153,6 @@ class ServerSettings(BaseModel): return v.split(";") return list() - @field_validator("allowed_interfaces", mode="before") @classmethod def split_allowed_interfaces(cls, v): @@ -162,27 +160,24 @@ class ServerSettings(BaseModel): return v.split(",") return list() - @model_validator(mode="after") def check_console_port_range(self) -> "ServerSettings": if self.console_end_port_range <= self.console_start_port_range: raise ValueError("console_end_port_range must be > console_start_port_range") return self - @model_validator(mode="after") def check_vnc_port_range(self) -> "ServerSettings": if self.vnc_console_end_port_range <= self.vnc_console_start_port_range: raise ValueError("vnc_console_end_port_range must be > vnc_console_start_port_range") return self - @model_validator(mode="after") def check_enable_ssl(self) -> "ServerSettings": if self.enable_ssl is True: - if self.certfile is None: + if not self.certfile: raise ValueError("SSL is enabled but certfile is not configured") - if self.certkey is None: + if not self.certkey: raise ValueError("SSL is enabled but certkey is not configured") return self diff --git a/gns3server/server.py b/gns3server/server.py index e17f2603..6673d81c 100644 --- a/gns3server/server.py +++ b/gns3server/server.py @@ -167,8 +167,10 @@ class Server: config.Server.allow_remote_console = args.allow config.Server.host = args.host config.Server.port = args.port - config.Server.certfile = args.certfile - config.Server.certkey = args.certkey + if args.certfile: + config.Server.certfile = args.certfile + if args.certkey: + config.Server.certkey = args.certkey config.Server.enable_ssl = args.ssl def _signal_handling(self):