You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let applications take over signature time validation #168
My ActivityPub server (mycroblog/my) accepts both RFC 9421 and draft-cavage signatures, and only RFC 9421 goes through httpsig. To keep one time policy for both schemes, the server checks the time window itself, before calling the library, using an injected clock. For RFC 9421 it rejects a signature when:
created is more than 1 hour in the future
expires, or created + 12 hours when there is no expires, passed more than 1 hour ago
Problem
WithMaxAge applies to created even when a signature has a later expires, so the library can't express this policy. WithCreatedTimestamp(false) and WithExpiresTimestamp(false) only make the parameters optional, and they are still checked when present. So I set WithMaxAge and WithValidityTolerance to 100 years to turn the checks off.
A correction to my PR comment: I framed this as a clock problem, but WithClock alone wouldn't remove this workaround. On the verification side, what I need is to turn the checks off.
Requirements
An explicit way to disable the verifier's time checks. It should be hard to do by accident, since the application then owns this check completely.
Lower priority: a time source for the signer. created comes from the system clock, while my server sets the Date header from its injected clock. Nothing is broken today, but both would ideally use the same source.
Possible shape
WithoutTimeValidation() as a VerifierOption, and WithClock(now func() time.Time) as a SignerOption. I'm happy to open a PR if you'd like this.
I see. What do you think about introducing a WithoutMaxAge() option? It would disable the maximum age check based on created, while the library would still ensure that created is not in the future (within the configured tolerance). The expires check would also remain unchanged. Would that help?
WithoutMaxAge() works for me. The library would still check expires and a future created, and my server would keep its 12-hour limit for signatures without expires, so I no longer need WithoutTimeValidation().
Separately, I'd still like to inject the time source, for tests, for verifying fixtures with fixed timestamps, and for keeping time in sync with another source such as the database. currentTime always follows the system clock, so when the application's time differs from it:
If the application's time is ahead, a freshly signed message fails with "signature not yet valid".
If it's behind, a signature with expires can fail with "signature expired", although it's still valid at the application's time.
The library's own tests have the same need: they replace currentTime to verify the RFC 9421 test vectors, which code outside the package can't do.
On a verifier, it's the time source for the expires and created checks. A verifier has one clock, so using it inside WithRequiredTag is a construction error.
On a signer, it's the time source for created, and for expires when it's derived from created.
A nil function is a construction error.
With both options, I could drop my 100-year WithMaxAge and WithValidityTolerance workaround. What do you think?
Let's go with WithoutMaxAge first and address WithClock separately.
Regarding WithClock: I just merged #183, which replaces the custom time patching used in our RFC test cases with testing/synctest, available since Go 1.25. Would this perhaps eliminate the need for WithClock? If not, could you please open a separate feature request for it? And feel free to submit a PR as well! :)
Thanks for #183! testing/synctest covers the test use case, so WithoutMaxAge is all I need for now. If I run into a production use case that really needs WithClock, I'll open a separate feature request then.
Activity
dadrus commentedon Nov 4, 2026
I see. What do you think about introducing a
WithoutMaxAge()option? It would disable the maximum age check based oncreated, while the library would still ensure thatcreatedis not in the future (within the configured tolerance). Theexpirescheck would also remain unchanged. Would that help?rosylilly commentedon Nov 5, 2026
WithoutMaxAge()works for me. The library would still checkexpiresand a futurecreated, and my server would keep its 12-hour limit for signatures withoutexpires, so I no longer needWithoutTimeValidation().Separately, I'd still like to inject the time source, for tests, for verifying fixtures with fixed timestamps, and for keeping time in sync with another source such as the database.
currentTimealways follows the system clock, so when the application's time differs from it:expirescan fail with "signature expired", although it's still valid at the application's time.The library's own tests have the same need: they replace
currentTimeto verify the RFC 9421 test vectors, which code outside the package can't do.So how about adding
WithClockfor both sides?expiresandcreatedchecks. A verifier has one clock, so using it insideWithRequiredTagis a construction error.created, and forexpireswhen it's derived fromcreated.With both options, I could drop my 100-year
WithMaxAgeandWithValidityToleranceworkaround. What do you think?dadrus commentedon Nov 5, 2026
Let's go with
WithoutMaxAgefirst and addressWithClockseparately.Regarding
WithClock: I just merged #183, which replaces the custom time patching used in our RFC test cases withtesting/synctest, available since Go 1.25. Would this perhaps eliminate the need forWithClock? If not, could you please open a separate feature request for it? And feel free to submit a PR as well! :)rosylilly commentedon Nov 6, 2026
Thanks for #183!
testing/synctestcovers the test use case, soWithoutMaxAgeis all I need for now. If I run into a production use case that really needsWithClock, I'll open a separate feature request then.