Modify server_config.json ssl cert fields

This commit is contained in:
Shreya 2021-06-07 20:07:07 +05:30
parent 2b73ec75c8
commit 42a9a79800
3 changed files with 13 additions and 2 deletions

View File

@ -99,6 +99,7 @@ def _start_island_server(should_setup_only, config_options: IslandConfigOptions)
http_server = WSGIServer(
("0.0.0.0", env_singleton.env.get_island_port()),
app,
# TODO: modify next two lines?
certfile=os.environ.get("SERVER_CRT", crt_path),
keyfile=os.environ.get("SERVER_KEY", key_path),
)

View File

@ -50,3 +50,8 @@ DEFAULT_START_MONGO_DB = True
DEFAULT_CRT_PATH = str(Path(MONKEY_ISLAND_ABS_PATH, "cc", "server.crt"))
DEFAULT_KEY_PATH = str(Path(MONKEY_ISLAND_ABS_PATH, "cc", "server.key"))
DEFAULT_CERTIFICATE_PATHS = {
"ssl_certificate_file": DEFAULT_CRT_PATH,
"ssl_certificate_key_file": DEFAULT_KEY_PATH,
}

View File

@ -3,6 +3,7 @@ from __future__ import annotations
import os
from monkey_island.cc.server_utils.consts import (
DEFAULT_CERTIFICATE_PATHS,
DEFAULT_CRT_PATH,
DEFAULT_DATA_DIR,
DEFAULT_KEY_PATH,
@ -24,10 +25,14 @@ class IslandConfigOptions:
).get("start_mongodb", DEFAULT_START_MONGO_DB)
self.crt_path = IslandConfigOptions._expand_path(
config_contents.get("cert_path", DEFAULT_CRT_PATH)
config_contents.get("ssl_certificate", DEFAULT_CERTIFICATE_PATHS).get(
"ssl_certificate_file", DEFAULT_CRT_PATH
)
)
self.key_path = IslandConfigOptions._expand_path(
config_contents.get("key_path", DEFAULT_KEY_PATH)
config_contents.get("ssl_certificate", DEFAULT_CERTIFICATE_PATHS).get(
"ssl_certificate_key_file", DEFAULT_KEY_PATH
)
)
@staticmethod