-
Notifications
You must be signed in to change notification settings - Fork 31
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
Function to return Datetime from an utcTime #34
Comments
True, the existing functions around Validity are primarily about creating validity records. I am working on a major rewrite, where much of the core functionality is handled by Erlang modules, and the Elixir modules are mostly about interworking with Elixir native data types. Validity would be one area where I imagine I'll end up with a rich Elixir interface. |
Actually, there is already an undocumented iex(3)> {:Validity, not_before, not_after} = X509.Certificate.validity(cert)
{:Validity, {:utcTime, '181001172413Z'}, {:utcTime, '191130233419Z'}}
iex(4)> X509.DateTime.to_datetime(not_before)
~U[2018-10-01 17:24:13Z]
iex(5)> DateTime.compare(DateTime.utc_now(), X509.DateTime.to_datetime(not_after))
:gt Don't tell anyone 🤫 |
Actually it's not conforming with the specification: https://tools.ietf.org/html/rfc5280#section-4.1.2.5.1 Not sure if people were doing X509 in the 60s though :) |
I might fix that in the rewrite. Right now Validity encoding, which is a public API, works correctly for dates from 1950 forward. Decoding only works starting from 2000, which is probably why I didn't make it public |
(Oops, again that annoying GH keyboard shortcut) |
X509 utcTime (and probably other date formats) are not trivial to parse to standard Elixir's
Datetime
. For instance, if YY is > 50 then it's 19xx, otherwise 20xx.It might prove useful to implement helper functions to deal with parsing dates of a
:Validity
record.The text was updated successfully, but these errors were encountered: