Search code examples
angulartypescriptdatetimex509certificateangular2-services

X509 Certificate does not display expiration date correctly. Is there a special format for the timestamp?


I'm having an issue where X509 certificate expiration timestamp logged from the console does not match it's actual timestamp from KeyStore explorer.

It is not formatting correctly with the Angular2+ built-in formatDate() function; an error is thrown. The timestamp is valid if the certificate is opened via KeyStore Explorer. Due to that, I think I have to program a custom date formatter myself.

X509 logged-from-console timestamp:

X509 logged-from-console timestamp

X509 KeystoreExplorer timestamp:

X509 KeystoreExplorer timestamp

How do you make sense of the day and time (12-347 vs 12/13; T19:08 vs 11:08AM)? Is there some special convention for X509 certificate times?


Solution

  • The error was on the Java-side. When propogating the date to the angular app, I was using DD instead of dd for the JSON formatting. DD returns the day of the year, instead of day of the month (dd).

    Change made:

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "YYYY-MM-dd'T'HH:mm:ss.sssZ")