haskell-tls / hs-certificate

Certificate and Key Reader/Writer in haskell
60 stars 57 forks source link

Certificate should not allow for factions of seconds. #119

Open fisx opened 4 years ago

fisx commented 4 years ago

I'd like to make a PR for this, but I have to say it's unlikely these days. But here is the issue, and the options, at least. I'd be interested in hearing what you maintainer(s) think. Thanks for this code!

Problem

the Certificate type contains DateTime which allows for fractions of seconds.

However, the rfc says, that there should only be full seconds.

This leads to the odd behavior that roundtrip serialization-deserialization changes some values of this type.

Options

  1. Make the type opaque and add a smart constructor that rounds the seconds.
  2. Add a custom date type that cannot carry fractions of seconds.

I like 2. better because it allows the constructor to be left exposed. Migrating to a new version where this happens could be made easier by offering a smart constructor that takes DateTime values, and maybe some more conversions functions if we can think of any.