#2598 Timestamps incorrectly stored in local time zone
Closed: migrated 3 years ago by dmoluguw. Opened 7 years ago by edewata.

In some places the code is encoding timestamps as follows:

SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss'Z'");
String string = formatter.format(timestamp);

However, it does not set the UTC time zone as follows:

formatter.setTimeZone(TimeZone.getTimeZone("UTC"));

So the resulting string is actually still in local time zone instead of UTC as implied by the 'Z' suffix, which could be misleading. Quoted text is not interpreted by the formatter. See http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html.

In DateMapper the problem may affect timestamps stored in the following fields in the database:

  • Certificate record:
    • dateOfCreate
    • dateOfModify
    • revokedOn
    • notAfter
    • notBefore
  • CRL record:
    • thisUpdate
    • nextUpdate
  • Key record:
    • dateOfCreate
    • dateOfModify
    • dateOfRecovery
  • Request record:
    • dateOfCreate
    • dateOfModify

In KRATool it may affect the timestamps stored in the LDIF files generated by this tool.

If everything that needs to use these timestamps (including PKI server) are always in the same time zone, this may not be a problem since encoding and decoding is done consistently using the same formatter. However, if PKI server is cloned/migrated into a different time zone the dates could be incorrectly decoded into the new time zone, possibly causing other issues.

One solution is to fix the timestamps manually in the database/LDIF files whenever the PKI server is cloned/migrated into a different time zone.

Another solution is to create a database upgrade script that will automatically converts the local timestamps into UTC timestamps into new fields and also modify the code to use the new fields and fix the timestamp formatter. This will allow changing time zones without changing the database, also allow clones to run in different time zones.


Metadata Update from @edewata:
- Issue set to the milestone: 0.0 NEEDS_TRIAGE

7 years ago

Metadata Update from @mharmsen:
- Custom field feature adjusted to ''
- Custom field proposedmilestone adjusted to '' (was: FUTURE)
- Custom field proposedpriority adjusted to '' (was: major)
- Custom field reviewer adjusted to ''
- Custom field version adjusted to ''
- Issue close_status updated to: None
- Issue priority set to: 3
- Issue set to the milestone: FUTURE (was: 0.0 NEEDS_TRIAGE)

7 years ago

Dogtag PKI is moving from Pagure issues to GitHub issues. This means that existing or new
issues will be reported and tracked through Dogtag PKI's GitHub Issue tracker.

This issue has been cloned to GitHub and is available here:
https://github.com/dogtagpki/pki/issues/2718

If you want to receive further updates on the issue, please navigate to the
GitHub issue and click on Subscribe button.

Thank you for understanding, and we apologize for any inconvenience.

Metadata Update from @dmoluguw:
- Issue close_status updated to: migrated
- Issue status updated to: Closed (was: Open)

3 years ago

Login to comment on this ticket.

Metadata