Skip to content

Conversation

@tomaswolf
Copy link
Member

Fixes:

  • Comparing certificate timestamps as unsigned longs
  • Test certificates without expiration date
  • Checking for correct certificate types (user/host) being used in correct contexts (host key, user auth)

tomaswolf added 3 commits May 26, 2021 21:28
Use Long.compareUnsigned() to compare them to determine whether a
certificate is still valid. OpenSSH uses ~0ULL to indicate "no
expiration time".
Previously these certificates had an expiration date of April 6, 2030.
This would have made tests fail after that date, and actually hid bug
SSHD-1172.

Adapt the OpenSSHCertificateTest to check the expected exception
message. This makes the test catch possible errors like comparing
certificate timestamps as signed integers (because we always check
expiration before checking principals).
Add checks that only host key certificates are used for host keys, and
only client certificates are used in pubkey authentication.

Also check the validity of the certificate in the server's
UserAuthPublicKey.
@tomaswolf tomaswolf merged commit 85d3c31 into apache:master May 26, 2021
@alex-sherwin
Copy link
Contributor

alex-sherwin commented May 27, 2021

I have a pending PR I was going to open tonight that touches some of this too, and in mine I changed the OpenSshCertificate valid before/after variables to Instant as it feels like a better developer experience to interact with (in my opinion).

I also found that there is some additional invalid encoding in the OpenSshCertificate code from the original certkeys PR that has gone unnoticed with the Critical Options/Extensions data.

My upcoming PR was to include code which can easily generate signed OpenSshCertificates, but ended up making the aforementioned fixes/changes as well (preview: https://github.com/alex-sherwin/mina-sshd2/pull/1)

@tomaswolf Would you prefer if I un-do my change of using Instant before submitting the final PR?

@tomaswolf
Copy link
Member Author

@alex-sherwin sorry about that. I had been thinking about Instant, too, but in the end I decided to just remove these two methods since I didn't need them. Converting to Instant would also have to take care of that unsigned long issue, and I didn't see a way to do that cleanly; best I could think of was to saturate the 64bit value at LONG_MAX. But if you have a clean solution I have nothing against using Instant at all.

If your change undoes some of what I did and solves it differently that's no problem.

@tomaswolf tomaswolf deleted the opensshcertificates branch June 7, 2022 07:07
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.

2 participants