Skip to content

Fix #771: OpenSSH @cert-authority and @revoked in known_hosts - #2713

Open
pavel-khritonenko wants to merge 5 commits into
paramiko:mainfrom
pavel-khritonenko:fix/771-cert-authority
Open

pavel-khritonenko wants to merge 5 commits into
paramiko:mainfrom
pavel-khritonenko:fix/771-cert-authority

Conversation

@pavel-khritonenko

Copy link
Copy Markdown

Fixes #771
Refs #2270

Summary

OpenSSH marker lines in known_hosts were previously mishandled: @cert-authority
and @revoked could be lost on save and were not used when verifying the server
host key. This change:

  • Parses and preserves @cert-authority and @revoked lines (including on
    HostKeys.save() / SSHClient.save_host_keys()).
  • Stores CA and revoked entries separately from pinned host keys.
  • Extends HostKeys.check() to honor revocation, pinned keys, and CA-backed
    trust for OpenSSH host certificates (validity window, principals, signature).
  • Sends host certificates in KEX where applicable and trusts them in
    SSHClient.connect() via HostKeys.check().

User-facing notes are in sites/docs/api/hostkeys.rst; changelog entry is under
the unreleased 5.2.0 section in sites/www/changelog.rst.

Test plan

  • uv run inv test (505 passed, 14 skipped locally)
  • Focused coverage: tests/test_hostkeys.py, tests/test_client.py,
    tests/pkey.py, tests/test_kex.py (KEX tests updated for asbytes_for_kex
    on FakeKey)

Fixtures live under tests/_support/host_ca_trust/ (test-only host CA + leaf cert).

Notes for reviewers

  • Certificate signature verification follows OpenSSH’s certify payload (sign
    through embedded CA key material, not the PROTOCOL.certkeys wrapper).
  • KEX uses PKey.asbytes_for_kex() so certificate material is on the wire
    without changing asbytes() / fingerprints used elsewhere.
  • Host cert algorithms supported in paramiko/ssh_cert.py: RSA (incl. rsa-sha2
    prefixes), Ed25519, ECDSA; other types fail closed.
  • No automatic pinning of the server key after CA-only trust (same as current
    test expectations).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Host-Keys signed by a CA aren't recognized as known hosts

1 participant