Skip to content

Commit e27dfd4

Browse files
authored
Merge pull request #2 from Snawoot/known_hosts_improvements
Known hosts improvements
2 parents ccb0cb0 + bb3c2a1 commit e27dfd4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

rsp/__main__.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,16 @@ def ssh_options_from_args(args, known_hosts):
110110

111111
async def amain(args, loop): # pragma: no cover
112112
logger = logging.getLogger('MAIN')
113-
known_hosts = asyncssh.read_known_hosts(args.hosts_file)
114-
matched_keys = known_hosts.match(args.dst_address, "", args.dst_port)[0]
115-
if not matched_keys:
113+
114+
try:
115+
known_hosts = asyncssh.read_known_hosts(args.hosts_file)
116+
except Exception as exc:
117+
logger.error("Host keys loading failed with error: %s", str(exc))
118+
host_keys, ca_keys, x509_certs, x509_subjects = [], [], [], []
119+
else:
120+
host_keys, ca_keys, _, x509_certs, _, x509_subjects, _ = \
121+
known_hosts.match(args.dst_address, "", args.dst_port)
122+
if not ( host_keys or ca_keys or x509_certs or x509_subjects ):
116123
logger.critical("Specified host is not found in known hosts. "
117124
"Please run following command: "
118125
"rsp-trust '%s' %d",

0 commit comments

Comments
 (0)