an2linuxserver.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:an2linuxserver 作者: rootkiwi 项目源码 文件源码
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''
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号