summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth Skousen <seth.skousen@mx.com>2020-03-11 17:16:03 -0600
committerSeth Skousen <seth.skousen@mx.com>2020-03-11 17:16:03 -0600
commit5660dcc8f62773bc4fe3d380a46e1eaf5fedd22a (patch)
tree7b20ae88bb4e666bfcdc72ff3fc8e29d0d1263fe
parent54476fa1e88a046014fa986792dbf2c65c5f17db (diff)
downloadnet-ssh-5660dcc8f62773bc4fe3d380a46e1eaf5fedd22a.tar.gz
Limit cert.valid_before to max supported by JRuby
-rw-r--r--lib/net/ssh/authentication/certificate.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/net/ssh/authentication/certificate.rb b/lib/net/ssh/authentication/certificate.rb
index ecf5df8..246ac94 100644
--- a/lib/net/ssh/authentication/certificate.rb
+++ b/lib/net/ssh/authentication/certificate.rb
@@ -31,7 +31,10 @@ module Net
cert.key_id = buffer.read_string
cert.valid_principals = buffer.read_buffer.read_all(&:read_string)
cert.valid_after = Time.at(buffer.read_int64)
- cert.valid_before = Time.at(buffer.read_int64)
+ # 0x20c49ba5e353f7 = 0x7fffffffffffffff/1000, the largest value possible for JRuby
+ # JRuby Time.at multiplies the arg by 1000, and then stores it in a signed long.
+ # 0x20c49ba5e353f7 = 292278994-08-17 01:12:55 -0600
+ cert.valid_before = Time.at([0x20c49ba5e353f7, buffer.read_int64].min)
cert.critical_options = read_options(buffer)
cert.extensions = read_options(buffer)
cert.reserved = buffer.read_string