Add precise control of ssh certificate validity using absolute time.
This PR introduces a new not_before_absolute field for SSH certificate roles, allowing users to specify the exact timestamp for when an SSH certificate should become valid. It should not be merged yet, as tests and documentation are lacking.
Key changes:
- Added the
not_before_absolutefield to the SSH role configuration. - Modified the certificate signing process to use the
not_before_absolutetime when set. - Included logic to give precedence to
not_before_absoluteovernot_before_durationwhen both are present. - Updated relevant structs and functions in the SSH package to accommodate the new field.
- Added error handling for invalid
not_before_absolutetime formats.
Rationale: To quote @mehmetakbulut on #24084:
- Many air-gapped systems without GPS and/or RTC boot up with their clocks set to the Unix epoch. These cannot accept a validity window starting at utc_now - not_before_duration.
- Certificates could be generated ahead of time for key rotation or other similar exercises with a future not_before date and remain invalid until rotation occurs.
The implementation maintains backward compatibility with the existing not_before_duration field, ensuring that current configurations continue to work as expected. I also deliberately chose to use the name not_before_absolute instead of just not_before as suggested in #485 and #24084. In my eyes, this seems a little less prone to confusion, but I can always change it if needed.
Next steps:
- [ ] Include the new field in tests across the project and ensure code coverage.
- [ ] Include usage examples in the project's documentation.
I decided to open this PR as is so I can check with the repo maintainers if everything is good so far with my commits since this is my first PR here. Work on tests and documentation will begin as soon as possible.
1.14.7
When you add unit tests, it would be great if you could add one for Unix epoch not_before="1970-01-01T00:00:00+00:00".
Hey, sorry for the delay!!
I just reimplemented it from the ground up with your suggestions in mind, I'm now trying to implement the tests but I have almost no experience with that, so I'll make sure to push it all so anyone can help me if they spot any code smell.
\o hey @vhespanha! Interested in finishing this up? Looks like our changes to ssh have caused this to conflict, sadly.
Hey! Yeah i'm really interested in finishing it, I haven't been able to do much for some time since I had some problems with my machine, but I plan on going back to this feature soon, thanks for asking.