def is_trusted_peer(self, peer: WSGreenBerryConnection, trusted_peers: Dict) -> bool:
    if (trusted_peers is None):
        return False
    for trusted_peer in trusted_peers:
        cert = (self.root_path / trusted_peers[trusted_peer])
        pem_cert = x509.load_pem_x509_certificate(cert.read_bytes())
        cert_bytes = pem_cert.public_bytes(encoding=serialization.Encoding.DER)
        der_cert = x509.load_der_x509_certificate(cert_bytes)
        peer_id = bytes32(der_cert.fingerprint(hashes.SHA256()))
        if (peer_id == peer.peer_node_id):
            self.log.debug(f'trusted node {peer.peer_node_id} {peer.peer_host}')
            return True
    return False
def is_trusted_peer(self, peer: WSGreenBerryConnection, trusted_peers: Dict) -> bool:
    if (trusted_peers is None):
        return False
    for trusted_peer in trusted_peers:
        cert = (self.root_path / trusted_peers[trusted_peer])
        pem_cert = x509.load_pem_x509_certificate(cert.read_bytes())
        cert_bytes = pem_cert.public_bytes(encoding=serialization.Encoding.DER)
        der_cert = x509.load_der_x509_certificate(cert_bytes)
        peer_id = bytes32(der_cert.fingerprint(hashes.SHA256()))
        if (peer_id == peer.peer_node_id):
            self.log.debug(f'trusted node {peer.peer_node_id} {peer.peer_host}')
            return True
    return False