Added a call to libssh2_knownhost_writefile()

Updated to the slightly modified libssh2_knownhost_check() proto
This commit is contained in:
Daniel Stenberg 2009-05-29 14:10:54 +02:00
parent 8cd76af353
commit 517909d37a

View File

@ -133,23 +133,26 @@ int main(int argc, char *argv[])
return 2;
}
/* read all hosts from here */
libssh2_knownhost_readfile(nh, "known_hosts",
LIBSSH2_KNOWNHOST_FILE_OPENSSH);
/* store all known hosts to here */
libssh2_knownhost_writefile(nh, "dumpfile",
LIBSSH2_KNOWNHOST_FILE_OPENSSH);
fingerprint = libssh2_session_hostkey(session, &len);
if(fingerprint) {
struct libssh2_knownhost host;
int check;
check = libssh2_knownhost_check(nh, (char *)hostname,
(char *)fingerprint, len,
LIBSSH2_KNOWNHOST_TYPE_PLAIN|
LIBSSH2_KNOWNHOST_KEYENC_RAW,
&host);
struct libssh2_knownhost *host;
int check = libssh2_knownhost_check(nh, (char *)hostname,
(char *)fingerprint, len,
LIBSSH2_KNOWNHOST_TYPE_PLAIN|
LIBSSH2_KNOWNHOST_KEYENC_RAW,
&host);
fprintf(stderr, "Host check: %d, key: %s\n", check,
(check <= LIBSSH2_KNOWNHOST_CHECK_MISMATCH)?
host.key:"<none>");
host->key:"<none>");
/*****
* At this point, we could verify that 'check' tells us the key is