2
0
mirror of https://github.com/ComradCollective/Comrad synced 2024-11-17 21:25:37 +00:00
This commit is contained in:
quadrismegistus 2020-09-14 19:28:26 +01:00
parent 8cdee61145
commit 33df5fcec9

View File

@ -41,17 +41,25 @@ class TheOperator(Operator):
self._keychain = {**self.load_keychain_from_bytes(keychain)} self._keychain = {**self.load_keychain_from_bytes(keychain)}
if not keychain.get('pubkey'): if not keychain.get('pubkey'):
raise KormadeException('Operator cannot find its own public key? Shutting down.') raise KomradeException('Operator cannot find its own public key? Shutting down.')
# check I match what's on op page # check I match what's on op page
pub_web = komrade_request(PATH_OPERATOR_WEB_KEYS_URL) pub_web = komrade_request(PATH_OPERATOR_WEB_KEYS_URL)
if pub_web == keychain.get('pubkey').data_b64_s: if pub_web.status_code!=200:
print('Pubs match') raise KomradeException("Can't verify Komrade Operator. Shutting down.")
print('Public key on komrade.app/pub: ',pub_web.text)
print('Public key hardcoded in client: ',keychain.get('pubkey').data_b64_s)
if pub_web.text == keychain.get('pubkey').data_b64_s:
# print('Pubs match')
pass
else: else:
raise KomradeException('Public key for Operator on app and one at {PATH_OPERATOR_WEB_KEYS_URL} do not match. Shutting down.') raise KomradeException('Public key for Operator on app and one at {PATH_OPERATOR_WEB_KEYS_URL} do not match. Shutting down.')
privkey=None privkey=None
if os.path.exists(PATH_SUPER_SECRET_OP_KEY): if os.path.exists(PATH_SUPER_SECRET_OP_KEY):
print('Dare I claim to be the one true Operator?')
with open(PATH_SUPER_SECRET_OP_KEY,'rb') as f: with open(PATH_SUPER_SECRET_OP_KEY,'rb') as f:
pass_encr=f.read() pass_encr=f.read()
try: try: