diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2018-06-04 10:57:55 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-06-04 11:20:28 +0200 |
commit | 5012a9c146c63032af59f264062b9e96c262bc66 (patch) | |
tree | 8e153195e968766a73a29e52687cb51e5ba3d8be | |
parent | 93781f9d5a2ee60520716610131e5642bb07ca92 (diff) | |
download | libssh-5012a9c146c63032af59f264062b9e96c262bc66.tar.gz libssh-5012a9c146c63032af59f264062b9e96c262bc66.tar.xz libssh-5012a9c146c63032af59f264062b9e96c262bc66.zip |
examples: Use new known hosts functions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r-- | examples/knownhosts.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/knownhosts.c b/examples/knownhosts.c index d06969f7..feacfa15 100644 --- a/examples/knownhosts.c +++ b/examples/knownhosts.c @@ -34,15 +34,13 @@ clients must be made or how a client should react. int verify_knownhost(ssh_session session){ char *hexa; - int state; + enum ssh_known_hosts_e state; char buf[10]; unsigned char *hash = NULL; size_t hlen; ssh_key srv_pubkey; int rc; - state=ssh_is_server_known(session); - rc = ssh_get_server_publickey(session, &srv_pubkey); if (rc < 0) { return -1; @@ -57,22 +55,24 @@ int verify_knownhost(ssh_session session){ return -1; } + state = ssh_session_is_known_server(session); + switch(state){ - case SSH_SERVER_KNOWN_OK: + case SSH_KNOWN_HOSTS_OK: break; /* ok */ - case SSH_SERVER_KNOWN_CHANGED: + case SSH_KNOWN_HOSTS_CHANGED: fprintf(stderr,"Host key for server changed : server's one is now :\n"); ssh_print_hexa("Public key hash",hash, hlen); ssh_clean_pubkey_hash(&hash); fprintf(stderr,"For security reason, connection will be stopped\n"); return -1; - case SSH_SERVER_FOUND_OTHER: + case SSH_KNOWN_HOSTS_OTHER: fprintf(stderr,"The host key for this server was not found but an other type of key exists.\n"); fprintf(stderr,"An attacker might change the default server key to confuse your client" "into thinking the key does not exist\n" "We advise you to rerun the client with -d or -r for more safety.\n"); return -1; - case SSH_SERVER_FILE_NOT_FOUND: + case SSH_KNOWN_HOSTS_NOT_FOUND: fprintf(stderr,"Could not find known host file. If you accept the host key here,\n"); fprintf(stderr,"the file will be automatically created.\n"); /* fallback to SSH_SERVER_NOT_KNOWN behavior */ @@ -104,7 +104,7 @@ int verify_knownhost(ssh_session session){ } break; - case SSH_SERVER_ERROR: + case SSH_KNOWN_HOSTS_ERROR: ssh_clean_pubkey_hash(&hash); fprintf(stderr,"%s",ssh_get_error(session)); return -1; |