def parse_authorized_certs():
if os.path.isfile(AUTHORIZED_CERTS_PATH):
with open(AUTHORIZED_CERTS_PATH, 'r') as f:
try:
authorized_certs = b''.join([base64.b64decode(line.split(' ')[1])
for line in f.readlines() if len(line.split(' ')) == 2])
# testing if valid certificates
ssl.SSLContext(protocol=ssl.PROTOCOL_TLSv1_2).load_verify_locations(cadata=authorized_certs)
return authorized_certs
except Exception as e:
print_with_timestamp('Corrupted authorized_certs file: {}'.format(e))
print_with_timestamp('Please look at authorized_certs and '
'search for obvious errors located at {}'.format(AUTHORIZED_CERTS_PATH))
print_with_timestamp('Or delete the file altogether, '
'but then you would have to pair your phone(s) again')
return b''
else:
return b''
评论列表
文章目录