broadfield-dev commited on
Commit
deab0d5
·
verified ·
1 Parent(s): cd6d009

Update server/app.py

Browse files
Files changed (1) hide show
  1. server/app.py +6 -6
server/app.py CHANGED
@@ -21,18 +21,18 @@ AES_GCM_NONCE_SIZE = 12
21
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
22
  logger = logging.getLogger(__name__)
23
 
24
- KEYLOCK_PRIV_KEY = os.environ.get('KEYLOCK_PRIV_KEY','./DEMO_ONLY_THIS _IS_SECRET_keylock_priv_key.pem')
25
  KEYLOCK_STATUS_MESSAGE = ""
26
-
27
  if not KEYLOCK_PRIV_KEY:
28
  try:
29
- with open("keylock_priv.pem", "r") as f:
30
  KEYLOCK_PRIV_KEY = f.read()
31
- logger.warning("Loaded private key from 'keylock_priv.pem'. This is for local testing only.")
32
- KEYLOCK_STATUS_MESSAGE = "⚠️ Loaded from `keylock_priv.pem` file. This is for local testing but insecure for production."
33
  except FileNotFoundError:
34
  logger.error("FATAL: Private key not found. API is non-functional.")
35
- KEYLOCK_STATUS_MESSAGE = "❌ NOT FOUND. The API is non-functional. Set the `KEYLOCK_PRIV_KEY` secret or provide a `keylock_priv.pem` file."
36
  else:
37
  logger.info("Successfully loaded private key from environment variable 'KEYLOCK_PRIV_KEY'.")
38
  KEYLOCK_STATUS_MESSAGE = "✅ Loaded successfully from secrets/environment variable. Recommended secure configuration."
 
21
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
22
  logger = logging.getLogger(__name__)
23
 
24
+ KEYLOCK_PRIV_KEY = os.environ.get('KEYLOCK_PRIV_KEY','./DEMO_ONLY_THIS_IS_SECRET_keylock_priv_key.pem')
25
  KEYLOCK_STATUS_MESSAGE = ""
26
+ KEY_DIR = "./keys/"
27
  if not KEYLOCK_PRIV_KEY:
28
  try:
29
+ with open(f"{KEY_DIR}keylock_priv.pem", "r") as f:
30
  KEYLOCK_PRIV_KEY = f.read()
31
+ logger.warning(f"Loaded private key from '{KEY_DIR}keylock_priv.pem'. This is for local testing only.")
32
+ KEYLOCK_STATUS_MESSAGE = f"⚠️ Loaded from `{KEY_DIR}keylock_priv.pem` file. This is for local testing but insecure for production."
33
  except FileNotFoundError:
34
  logger.error("FATAL: Private key not found. API is non-functional.")
35
+ KEYLOCK_STATUS_MESSAGE = f"❌ NOT FOUND. The API is non-functional. Set the `KEYLOCK_PRIV_KEY` secret or provide a `{KEY_DIR}keylock_priv.pem` file."
36
  else:
37
  logger.info("Successfully loaded private key from environment variable 'KEYLOCK_PRIV_KEY'.")
38
  KEYLOCK_STATUS_MESSAGE = "✅ Loaded successfully from secrets/environment variable. Recommended secure configuration."