diff --git a/gns3server/schemas/config.py b/gns3server/schemas/config.py index 27a4ca2d6..f5155ec30 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 @@ def split_additional_images_paths(cls, v): return v.split(";") return list() - @field_validator("allowed_interfaces", mode="before") @classmethod def split_allowed_interfaces(cls, v): @@ -162,27 +160,24 @@ def split_allowed_interfaces(cls, v): 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 e17f26035..6673d81cd 100644 --- a/gns3server/server.py +++ b/gns3server/server.py @@ -167,8 +167,10 @@ def _set_config_defaults_from_command_line(args): 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):