Add host certificate support to server and client#641
Conversation
2781c38 to
1fe6853
Compare
|
This seems to be the server part only, right? If I run my minimal client example against a host certificate only OpenSSH server, I get this error: The following |
|
Thanks for testing, my test uses ed25519 and sets it as the prefered algo. |
c031d99 to
39de561
Compare
|
I added support for rsa certificats and fixed some other issues. |
|
I pulled you new version |
|
I read your code and I think I firgured out what goes wrong. You are not providing a certificate during the intialization to the client, therefore it does not add any certificate handling algo to the list of available host key algos. I see that this is not the most elegant way and I am working on a more obvios one. |
|
Thanks for investigation my issue. I added this to my config based on your code example in the PR: For me, it was not very intuitive that After adding certificate algorithms to This is the output of my test app: |
bfb7223 to
6355835
Compare
|
ok, i did some more work on this, added the ca_public_key. I also did some testing thie a openssh server configured as you described, now I optimistic that it works. this is a client code i used: |
|
Thank you for updating your MR and providing a client example. The API looks much nicer now than in the previous version that used the When connecting to my server with openssh and only this single line in my However, when I run your example with only the CA-pubkey and IP address adjusted, I still get: |
|
hm, interesting. Would you share you ssh server configuration, so I can try to figure out the differences and why the code works with my ssh server config but not yours? |
|
Hi @gvz, I did some further testing and figured out that the issue is related to the processing of host certificates with unlimited validity. I generated my test PKI and certificates with the following commands: Then I added this to Generate a test host certificate with infinite validity: Adding an expiry time makes it work: For reference, this is my |
|
thanks for your help, ssh has so many fun ways to make my code fail. |
|
@maximilian-maisel-bl It looks like the internal https://github.com/Eugeny/RustCrypto-SSH/ has problems with infintiv livetimes. |
this adds ca_public_key to the client config, if not none this adds the the algorhism corresponding to the ones advertised while connecting to a host
Co-authored-by: louib <code@louib.net> Co-authored-by: Eugene <inbox@null.page>
this adds ca_public_key to the client config, if not none this adds the the algorhism corresponding to the ones advertised while connecting to a host
- Update check_server_key impls in tests.rs to accept &PublicKeyOrCertificate - Replace removed OsRng import with rand::rng() in test_server_cert.rs
|
I opened a pull request to upstream ssh-key repo that fixes the certificate validity issue: |
b6b90a5 to
1a8b123
Compare
…4::MAX) OpenSSH PROTOCOL.certkeys specifies that valid_before=0xffffffffffffffff (u64::MAX) means the certificate never expires. The forked ssh-key crate previously rejected this value in UnixTime::new, causing Certificate::from_bytes to fail for infinite-validity certs. The client kex code silently fell through to the plain public-key path, which also failed — breaking connections to any server whose host certificate was generated without the -V flag. Fixes: - russh-ssh-key: add FOREVER_SECS sentinel and cap its SystemTime at MAX_SECS so u64::MAX round-trips through encoding correctly - Cargo.toml: patch ssh-encoding to the bundled path dep to avoid two-instance type mismatch between path and registry versions of the same crate - tests: add test_server_infinite_validity_certificate_auth regression test
primefield 0.14.0-rc.7 fails to compile on Rust 1.88.0 due to const generic type inference regression. Raising the floor on p256/p384/p521 to rc.9 ensures cargo minimal-versions resolves primefield to rc.9+.
…-versions CI ed25519 rc.4 and ed25519-dalek pre.6 use Error::KeyMalformed as a unit variant, incompatible with pkcs8 0.11 stable which changed it to a tuple variant. Pin ed25519 to 3.0.0 stable and raise ed25519-dalek floor to pre.7 so cargo minimal-versions never selects the broken versions.
num-bigint 0.4.0 calls div_ceil(&x) which broke when Rust 1.73 stabilized div_ceil(x) by value. yasna 0.5.0 depends on num-bigint with no floor, so minimal-versions resolves to 0.4.0.
ctr 0.10.0-rc.3 uses cipher::common::BlockSizes which doesn't exist in cipher 0.5 stable. Add aliased floor pin to force 0.10.0 stable while keeping russh's direct dep on ctr 0.9 (compatible with aes 0.8).
|
RustCrypto/SSH#504 got merged to upstream rustCrypto |
This adds support for host certificats to russh and fixes #416.
It was tested with the openssh client and the added test.
There are two test: the first test the happy path for server and client.
The second one test whether the Certificate::validate function can detect if the host presents a certificate that is singned by an untrusted authority and reject it.
I also added an example, echoserver-certificate.
Let me know what you would like me to improove to get this merged.