Skip to content

ssh-key: accept u64::MAX as OpenSSH "no expiry" sentinel in UnixTime#504

Open
gvz wants to merge 1 commit intoRustCrypto:masterfrom
gvz:master
Open

ssh-key: accept u64::MAX as OpenSSH "no expiry" sentinel in UnixTime#504
gvz wants to merge 1 commit intoRustCrypto:masterfrom
gvz:master

Conversation

@gvz
Copy link
Copy Markdown

@gvz gvz commented May 8, 2026

OpenSSH PROTOCOL.certkeys specifies that valid_before=0xffffffffffffffff (u64::MAX) means the certificate never expires. Previously UnixTime::new rejected this value because it exceeds MAX_SECS (i64::MAX), causing Certificate parsing to fail for any cert generated without an explicit validity window (e.g. ssh-keygen -s ca -h key.pub without -V).

Add FOREVER_SECS=u64::MAX constant. In new(), cap its SystemTime representation at MAX_SECS to keep a valid SystemTime while preserving the raw secs value for round-trip encoding correctness.

Fixes: #503

OpenSSH PROTOCOL.certkeys specifies that valid_before=0xffffffffffffffff
(u64::MAX) means the certificate never expires. Previously UnixTime::new
rejected this value because it exceeds MAX_SECS (i64::MAX), causing
Certificate parsing to fail for any cert generated without an explicit
validity window (e.g. ssh-keygen -s ca -h key.pub without -V).

Add FOREVER_SECS=u64::MAX constant. In new(), cap its SystemTime
representation at MAX_SECS to keep a valid SystemTime while preserving
the raw secs value for round-trip encoding correctness.

Fixes: RustCrypto#503
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.

certificates with infinite validity fail to parse

1 participant