Skip to content

Support RSA certificate authentication - #710

Merged
willco007 merged 2 commits into
libssh2:masterfrom
msabansal:signedrsa
Jul 28, 2022
Merged

willco007 merged 2 commits into
libssh2:masterfrom
msabansal:signedrsa

Conversation

@msabansal

Copy link
Copy Markdown
Contributor

This PR is based of https://github.com/libssh2/libssh2/pull/570/files and just the tests were fixed to make sure everything works smoothly.

@msabansal

Copy link
Copy Markdown
Contributor Author

@willco007 do you mind taking a look at this. I am not sure if the test failure is a code issue. does rerun fix it or not

@mback2k

mback2k commented Jun 15, 2022 •

Copy link
Copy Markdown
Member

It seems like the tests are broken on Windows. You can re-run by doing an amend and force-push.

@msabansal

Copy link
Copy Markdown
Contributor Author

@mback2k just to clarify by tests are broken you mean this seems to be a flaky test?

@mback2k

mback2k commented Jun 15, 2022

Copy link
Copy Markdown
Member

No, in that case the tests themselves are not flaky, just the CI platform is sometimes.

@msabansal

Copy link
Copy Markdown
Contributor Author

got it thanks for the clarification. Running the tests again.

@msabansal

Copy link
Copy Markdown
Contributor Author

Can someone please review and if there is a follow up please let me know.

@msabansal

Copy link
Copy Markdown
Contributor Author

@willco007 Can you please take a look and let me know if there is anything more required on this. Thanks

@msabansal

Copy link
Copy Markdown
Contributor Author

@willco007 Checking if you can take a look at this.

@willco007
willco007 merged commit 4b21e49 into libssh2:master Jul 28, 2022
@msabansal
msabansal deleted the signedrsa branch July 28, 2022 16:19
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 2, 2023
Replace incorrect `MD5_DIGEST_LENGTH` with `SHA1_DIGEST_LENGTH` for
these hostkey algos:

- ssh-rsa and ssh-dss

  Ref: 7a5ffc8 (2004-12-07 Initial)

- [email protected]

  Ref: 4b21e49 (2022-07-28)
  Ref: libssh2#710

Reported-by: Markus-Schmidt on github
Fixes libssh2#919
Closes #xxx
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 2, 2023
Replace incorrect `MD5_DIGEST_LENGTH` with `SHA1_DIGEST_LENGTH` for
these hostkey algos:

- ssh-rsa and ssh-dss

  Ref: 7a5ffc8 (2004-12-07 Initial)

- [email protected]

  Ref: 4b21e49 (2022-07-28)
  Ref: libssh2#710

Reported-by: Markus-Schmidt on github
Fixes libssh2#919
Closes #xxx
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 2, 2023
Replace incorrect `MD5_DIGEST_LENGTH` with `SHA1_DIGEST_LENGTH` for
these hostkey algos:

- ssh-rsa and ssh-dss

  Ref: 7a5ffc8 (2004-12-07 Initial)

- [email protected]

  Ref: 4b21e49 (2022-07-28)
  Ref: libssh2#710

Reported-by: Markus-Schmidt on github
Fixes libssh2#919
Closes #xxx
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 2, 2023
Replace incorrect `MD5_DIGEST_LENGTH` with `SHA1_DIGEST_LENGTH` for
these hostkey algos:

- `ssh-rsa` and `ssh-dss`

  Ref: 7a5ffc8 (2004-12-07 Initial)

- `[email protected]`

  Ref: 4b21e49 (2022-07-28)
  Ref: libssh2#710

Also delete local fall-back definition of `MD5_DIGEST_LENGTH` (added
in 9af7eb4). Macro is no longer used.

Reported-by: Markus-Schmidt on github
Fixes libssh2#919
Closes libssh2#926
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 2, 2023
Replace incorrect `MD5_DIGEST_LENGTH` with `SHA_DIGEST_LENGTH` for
these hostkey algos:

- `ssh-rsa` and `ssh-dss`

  Ref: 7a5ffc8 (2004-12-07 Initial)

- `[email protected]`

  Ref: 4b21e49 (2022-07-28)
  Ref: libssh2#710

Also delete local fall-back definition of `MD5_DIGEST_LENGTH` (added
in 9af7eb4). Macro is no longer used.

Reported-by: Markus-Schmidt on github
Fixes libssh2#919
Closes libssh2#926
vszakats added a commit that referenced this pull request Apr 3, 2023
Replace incorrect `MD5_DIGEST_LENGTH` with `SHA_DIGEST_LENGTH` for these
hostkey algos:

- `ssh-rsa` and `ssh-dss`

  Ref: 7a5ffc8 (2004-12-07 Initial)

- `[email protected]`

  Ref: 4b21e49 (2022-07-28)
  Ref: #710

Also delete local fall-back definition of `MD5_DIGEST_LENGTH` (added
in 9af7eb4). Macro is no longer used.

Reported-by: Markus-Schmidt on github
Fixes #919
Closes #926
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
Replace incorrect `MD5_DIGEST_LENGTH` with `SHA_DIGEST_LENGTH` for these
hostkey algos:

- `ssh-rsa` and `ssh-dss`

  Ref: 7a5ffc8 (2004-12-07 Initial)

- `[email protected]`

  Ref: 4b21e49 (2022-07-28)
  Ref: libssh2#710

Also delete local fall-back definition of `MD5_DIGEST_LENGTH` (added
in 9af7eb4). Macro is no longer used.

Reported-by: Markus-Schmidt on github
Fixes libssh2#919
Closes libssh2#926
@vszakats
vszakats requested a review from Copilot August 2, 2026 08:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

The newly added RSA test and fixture files are not reflected in the Autotools tests/Makefile.am distribution list, which can break make dist packaging for non-CMake consumers.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR extends libssh2’s publickey authentication support to handle RSA user certificates ([email protected]) and adds/updates OpenSSH integration test assets to validate the behavior in CI.

Changes:

  • Add RSA certificate hostkey method registration and ensure the “plain” method name is used in the phase-2 publickey auth request for RSA certs.
  • Add a new integration test plus RSA signed key fixtures, and update the OpenSSH test container to trust both ECDSA and RSA user CAs.
  • Minor test infrastructure housekeeping (Docker base image refresh, .gitignore update, formatting fix).
File summaries
File Description
tests/test_public_key_auth_succeeds_with_correct_signed_rsa_key.c New integration test for RSA certificate-based publickey authentication.
tests/signed_key_rsa Test RSA private key fixture (OpenSSH format).
tests/signed_key_rsa.pub Test RSA public key fixture.
tests/signed_key_rsa-cert.pub Test RSA certificate public key fixture.
tests/openssh_server/Dockerfile Updates OpenSSH server image, trusts both ECDSA and RSA CAs for user certificates, and adjusts accepted key types.
tests/openssh_server/ca_rsa RSA CA private key fixture for the OpenSSH test server environment.
tests/openssh_server/ca_rsa.pub RSA CA public key fixture used by TrustedUserCAKeys.
tests/openssh_fixture.c Trivial formatting fix.
tests/CMakeLists.txt Registers the new RSA cert auth test in the CMake test suite.
src/userauth.c Adds RSA cert handling to the “plain method length” logic used in phase-2 publickey auth.
src/hostkey.c Registers [email protected] hostkey method mapping to RSA signing backend.
.gitignore Ignores build directory.
Review details
  • Files reviewed: 10/12 changed files
  • Comments generated: 1
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread tests/CMakeLists.txt
Comment on lines 136 to 145
if(OPENSSL_VERSION VERSION_GREATER "1.1.0")
list(APPEND TESTS
public_key_auth_succeeds_with_correct_ed25519_key
public_key_auth_succeeds_with_correct_encrypted_ed25519_key
public_key_auth_succeeds_with_correct_ed25519_key_from_mem
public_key_auth_succeeds_with_correct_ecdsa_key
public_key_auth_succeeds_with_correct_signed_ecdsa_key
public_key_auth_succeeds_with_correct_signed_rsa_key
)
endif()
vszakats added a commit that referenced this pull request Aug 2, 2026
…ig` to accept it

Explicitly use `-t ssh-rsa` (signature algorithm) to generate
`id_rsa_signed.pub` to match the purpose of the patch it came with. Also
to differenciate this key (and test) from the subsequently merged
`id_rsa_sha2_512_signed-cert.pub`, which used the exact same keys (`-t
rsa-sha2-512`, the default) before this patch, and made these tests
duplicates.

Also:
- update `sshd_config` to actually allow using an obsolete/insecure
  certificate signature `ssh-rsa`, by adding it to `CASignatureAlgorithms`.
- delete recently added entry from `HostKeyAlgorithms`, it was not
  necessary.
  Follow-up to 5b494b0 #2478

Testing obsolete/insecure algs is not time best spent in CI and for
maintainers, so maybe in a next step it'd useful to disable the RSA
SHA1-based ones by default.

Ref: https://superuser.com/questions/1556852/how-to-check-if-your-ssh-keys-are-in-the-ssh-rsa2-format
Ref: 7392dc9 #2479
Follow-up to 4b21e49 #710

Closes #2474
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.

4 participants