www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: [libssh2] #276: do not fail when keys of unknown type are read from known_hosts file

[libssh2] #276: do not fail when keys of unknown type are read from known_hosts file

From: libssh2 Trac <trac_at_libssh2.stuge.se>
Date: Fri, 04 Oct 2013 09:21:17 -0000

#276: do not fail when keys of unknown type are read from known_hosts file
--------------------+--------------------
 Reporter: salva | Owner:
     Type: defect | Status: new
 Priority: normal | Milestone: 1.4.3
Component: misc | Version: 1.4.2
 Keywords: | Blocked By:
   Blocks: |
--------------------+--------------------
 Currently, when `libssh2_knownhost_readfile` finds a key of a type not
 natively supported by the library, it stops reading and returns an error.

 This is very annoying as OpenSSH uses other key types and so its
 known_host can not be used. Even worse, if the programmer is sloppy, and
 doesn't check for errors when calling `libssh2_knownhost_readfile` and
 later saves the file, it will wipe out any entries after the unsupported
 one.

 The attached patch solves that issue.

 Commit log follows:

 {{{
     store but don't use keys of unsupported types on the known_hosts
     file.

     Currently, when libssh2 parses a known_host file containing keys
     of some type it doesn't natively support, it stops reading the
      file and returns an error.

     That means, that the known_host file can not be safely shared
     with other software supporting other key types (i.e. OpenSSH).

     This patch adds support for handling keys of unknown type. It can
     read and write them, even if they are never going to be matched.

     At the source level the patch does the following things:

     - add a new unknown key type LIBSSH2_KNOWNHOST_KEY_UNKNOWN

     - add a new slot (key_type_name) on the known_host struct that is
     used to store the key type in ascii form when it is not supported

     - parse correctly known_hosts entries with unknown key types and
     populate the key_type_name slot

     - print correctly known_hosts entries of unknown type

     - when checking a host key ignore keys that do not match the key
     type
 }}}

-- 
Ticket URL: <https://trac.libssh2.org/ticket/276>
libssh2 <https://trac.libssh2.org/>
C library for writing portable SSH2 clients
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2013-10-04

the libssh2 team