Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use known host algorithm #707

Closed
wants to merge 16 commits into from
Closed

Use known host algorithm #707

wants to merge 16 commits into from

Conversation

WorkDayHeyHey
Copy link
Contributor

@WorkDayHeyHey WorkDayHeyHey commented Aug 12, 2021

#642 #635 etc.

There are a lot of issues with this, in various words. I hit it first thing when I tried an example, and as I really need a new SSH library and my outside fix was dirty, here is a patch.

I haven't done this github thing very much and that was a little a long time ago. So help me out. Reading the pull request how to, it sounds like I should do this in a feature branch. I started out like that but messed up and didn't want to push a dirty commit. So I can easily do this again if that's better.

Bernie Day added 2 commits August 12, 2021 14:00
Try to find the Algorithm that was used when a known_host
entry was created and make that the first choice for the
current connection attempt.

If the current connection algorithm matches the
algorithm used when the known_host entry was created
we can get a fair verification.
This code base has a lot of instances where an
exception is thrown as part of the logic path.
That makes it very hard to follow and debug.

In Scala I use built in Types to encapsulate
the results of a method calls that may have
non-determinate results. I wrote something
like this version of PossibleResult for a
Java project recently, it used Optional
instead of null.

You may want to include this and use it,
or not.
@WorkDayHeyHey WorkDayHeyHey marked this pull request as draft August 12, 2021 18:49
@WorkDayHeyHey
Copy link
Contributor Author

This works as far as I can tell. I didn't add any tests. All your unit tests still pass. Since I haven't use Gradle in years I didn't try to get into those tests at all.

It fixes my issue with accessing hosts with varying known host algorithms.

@WorkDayHeyHey WorkDayHeyHey marked this pull request as ready for review August 12, 2021 18:59
Bernie Day and others added 2 commits August 16, 2021 13:40
The hostnames saved in known_hosts are forced to lower case,
we need to do the same to match.
@hierynomus
Copy link
Owner

After bringing this up to date with master, it breaks the integration tests.

@WorkDayHeyHey
Copy link
Contributor Author

WorkDayHeyHey commented Sep 21, 2021 via email

@WorkDayHeyHey
Copy link
Contributor Author

WorkDayHeyHey commented Sep 21, 2021 via email

@WorkDayHeyHey
Copy link
Contributor Author

WorkDayHeyHey commented Sep 21, 2021 via email

@hierynomus
Copy link
Owner

We all learn ;)

BTW, I think the PossibleResult class that you added is dead code? Can you remove it from the PR?

@WorkDayHeyHey
Copy link
Contributor Author

WorkDayHeyHey commented Sep 21, 2021 via email

Bernie Day and others added 12 commits September 22, 2021 11:13
If key-type from known_hosts isn't in the configured
key algorithm list, don't add it to the list of
algorithms to try.
This kind of thing might really make it easier to
follow the logic path, but as there is already a
huge base of exception throwing code, retrofitting
something like this would be a lot of work. Still
a little in the right spot might make things a lot
easier for a log time to come.
The hostnames saved in known_hosts are forced to lower case,
we need to do the same to match.
* Handle @cert-authority in known_hosts.

* Fix ClassCastException when receiving an ECDSA-CERT host key.

* Mention what exactly is not negotiated.

* Verify host key certificates during key exchange.

* Unit and integration tests for host key verification.

* Show sshd logs when integration test finishes.

* Review fixes: extract to private method, change strings.
* Enhanced PKCS8 parsing to support PEM ASN.1 Private Keys

* Corrected copyright year to match existing license headers
- Added unit tests for encrypted PKCS8 RSA Private Key
- Renamed BCryptTest and updated using JUnit Test annotations
* Support v3 PuTTY keys

* add test for putty v3 key

* Format PuTTYKeyFile to fix Codacy warnings

Signed-off-by: Jeroen van Erp <jeroen@hierynomus.com>

Co-authored-by: Jeroen van Erp <jeroen@hierynomus.com>
If key-type from known_hosts isn't in the configured
key algorithm list, don't add it to the list of
algorithms to try.
@WorkDayHeyHey
Copy link
Contributor Author

WorkDayHeyHey commented Sep 22, 2021 via email

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.

5 participants