Esempio n. 1
0
def download_backend_hostkey():
    """Get Bastio's backend SSH host key.

    :returns:
        :class:`bastio.ssh.crypto.RSAKey`
    :raises:
        :class:`bastio.excepts.BastioAccountError`
    """
    errmsg = "get backend host key failed: "

    response = __send_request('get', url=__download_hostkey_endpoint, verify=True)
    if response.status_code != requests.codes.okay: # 200
        raise BastioAccountError(errmsg + "unable to retrieve backend's host key")

    public_key = response.json()['payload']
    if not RSAKey.validate_public_key(public_key):
        raise BastioAccountError(errmsg + "invalid host key")
    return RSAKey.from_public_key(public_key)
 def test_key_loading(self):
     pubkey = self.key.get_public_key()
     self.assertIsInstance(RSAKey.from_public_key(pubkey), RSAKey)