Esempio n. 1
0
 def test_certs_allowed_as_key_filename_values(self):
     # NOTE: giving cert path here, not key path. (Key path test is below.
     # They're similar except for which path is given; the expected auth and
     # server-side behavior is 100% identical.)
     # NOTE: only bothered whipping up one cert per overall class/family.
     for type_ in ('rsa', 'dss', 'ecdsa_256', 'ed25519'):
         cert_path = test_path('test_{0}.key-cert.pub'.format(type_))
         self._test_connection(
             key_filename=cert_path,
             public_blob=PublicBlob.from_file(cert_path),
         )
Esempio n. 2
0
 def test_certs_allowed_as_key_filename_values(self):
     # NOTE: giving cert path here, not key path. (Key path test is below.
     # They're similar except for which path is given; the expected auth and
     # server-side behavior is 100% identical.)
     # NOTE: only bothered whipping up one cert per overall class/family.
     for type_ in ("rsa", "dss", "ecdsa_256", "ed25519"):
         cert_name = "test_{}.key-cert.pub".format(type_)
         cert_path = _support(os.path.join("cert_support", cert_name))
         self._test_connection(
             key_filename=cert_path,
             public_blob=PublicBlob.from_file(cert_path),
         )
Esempio n. 3
0
 def test_certs_allowed_as_key_filename_values(self):
     # NOTE: giving cert path here, not key path. (Key path test is below.
     # They're similar except for which path is given; the expected auth and
     # server-side behavior is 100% identical.)
     # NOTE: only bothered whipping up one cert per overall class/family.
     for type_ in ("rsa", "dss", "ecdsa_256", "ed25519"):
         cert_name = "test_{}.key-cert.pub".format(type_)
         cert_path = _support(os.path.join("cert_support", cert_name))
         self._test_connection(
             key_filename=cert_path,
             public_blob=PublicBlob.from_file(cert_path),
         )
Esempio n. 4
0
 def test_certs_implicitly_loaded_alongside_key_filename_keys(self):
     # NOTE: a regular test_connection() w/ test_rsa.key would incidentally
     # test this (because test_xxx.key-cert.pub exists) but incidental tests
     # stink, so NullServer and friends were updated to allow assertions
     # about the server-side key object's public blob. Thus, we can prove
     # that a specific cert was found, along with regular authorization
     # succeeding proving that the overall flow works.
     for type_ in ('rsa', 'dss', 'ecdsa_256', 'ed25519'):
         key_path = test_path('test_{0}.key'.format(type_))
         self._test_connection(
             key_filename=key_path,
             public_blob=PublicBlob.from_file(
                 '{0}-cert.pub'.format(key_path)),
         )
Esempio n. 5
0
 def test_certs_implicitly_loaded_alongside_key_filename_keys(self):
     # NOTE: a regular test_connection() w/ test_rsa.key would incidentally
     # test this (because test_xxx.key-cert.pub exists) but incidental tests
     # stink, so NullServer and friends were updated to allow assertions
     # about the server-side key object's public blob. Thus, we can prove
     # that a specific cert was found, along with regular authorization
     # succeeding proving that the overall flow works.
     for type_ in ("rsa", "dss", "ecdsa_256", "ed25519"):
         key_name = "test_{}.key".format(type_)
         key_path = _support(os.path.join("cert_support", key_name))
         self._test_connection(
             key_filename=key_path,
             public_blob=PublicBlob.from_file(
                 "{}-cert.pub".format(key_path)),
         )
Esempio n. 6
0
def check_publickey(args: argparse.Namespace) -> bool:
    key = open(args.public_key, 'rt').read()
    try:
        pubkey = PublicBlob.from_string(key)
    except ValueError:
        print("file is not a valid public key")
        return False
    if probe_host(hostname_or_ip=args.host,
                  port=args.port,
                  username=args.username,
                  public_key=pubkey):
        print("valid key")
        return True
    print("bad key")
    return False
Esempio n. 7
0
 def test_certs_implicitly_loaded_alongside_key_filename_keys(self):
     # NOTE: a regular test_connection() w/ test_rsa.key would incidentally
     # test this (because test_xxx.key-cert.pub exists) but incidental tests
     # stink, so NullServer and friends were updated to allow assertions
     # about the server-side key object's public blob. Thus, we can prove
     # that a specific cert was found, along with regular authorization
     # succeeding proving that the overall flow works.
     for type_ in ("rsa", "dss", "ecdsa_256", "ed25519"):
         key_name = "test_{}.key".format(type_)
         key_path = _support(os.path.join("cert_support", key_name))
         self._test_connection(
             key_filename=key_path,
             public_blob=PublicBlob.from_file(
                 "{}-cert.pub".format(key_path)
             ),
         )