From cfdf1183f546b9cc9c78c2be5daee6b5b05ac483 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Fri, 18 Jun 2021 12:30:46 +0300 Subject: [PATCH] Fix invalid handle for mongo key file error by using the filename instead --- monkey/monkey_island/cc/server_utils/encryptor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/server_utils/encryptor.py b/monkey/monkey_island/cc/server_utils/encryptor.py index 83292be8a..657a06e87 100644 --- a/monkey/monkey_island/cc/server_utils/encryptor.py +++ b/monkey/monkey_island/cc/server_utils/encryptor.py @@ -25,9 +25,10 @@ class Encryptor: else: self._init_key(password_file) - def _init_key(self, password_file): + def _init_key(self, password_file_path: str): self._cipher_key = Random.new().read(self._BLOCK_SIZE) - with open(get_file_descriptor_for_new_secure_file(path=password_file), "wb") as f: + get_file_descriptor_for_new_secure_file(path=password_file_path) + with open(password_file_path, "wb") as f: f.write(self._cipher_key) def _load_existing_key(self, password_file):