Add initial support for X.509 certificate authentication
This commit adds initial support for X.509 certificate based authentication of users and hosts, as defined in RFC 6187. There's no support yet for OCSP validation, but otherwise the functionality is reasonably complete, supporting full certificate chain validation, subject alternative name support for user and host principals, and the ability to configure trust by matching on certificate subject names in addition to specific certificates or public keys. Trusted root CAs can be specified via a new x509_trusted_certs argument to the create_connection() and create_server() functions. There's also a new x509_purposes argument which can be used to specify what purpose values must be in an X.509 certificates ExtendedKeyUsage to be valid for SSH authentication. This new functionality can be disabled by explicitly setting x509_trusted_certs to None. Support has also been added to allow trusted client, server, or CA certificates to be specified in authorized_keys and known_hosts files, with a syntax compatible with the PKIX-SSH patches which add this functionality to OpenSSH. New functions generate_x509_user_certificate(), generate_x509_host_certificate(), and generate_x509_ca_certificate() have been added to the SSHKey class, to allow creation of X.509 certificate chains. A new top-level load_certificates() function has also been added as a convenience if you wish to load a collection of certificates in prior to calling create_connection() or create_server(). To use this support, pyOpenSSL must be installed to perform certificate chain validation. This dependency will be removed if this support is ever added in the base cryptography package. Certificate-based algorithms (for both X.509 and OpenSSH) are now listed ahead of key-based algorithms when constructing a list of supported host key algorithms.
R
Ron Frederick committed
a6b8b2edc837a86a9f991b27c638b7eb4c6b9d04
Parent: 4f1edc8