Skip to content

Commit

Permalink
Fix #846
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis <alexis.challande@trailofbits.com>
  • Loading branch information
DarkaMaul committed Oct 4, 2024
1 parent af6129b commit 793b720
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/api/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ func TimestampResponseHandler(params ts.GetTimestampResponseParams) middleware.R
tsStruct := timestamp.Timestamp{
HashAlgorithm: req.HashAlgorithm,
HashedMessage: req.HashedMessage,
Time: time.Now(),
// The field here is going to be serialized as a GeneralizedTime, and RFC5280
// states that the GeneralizedTime values MUST be expressed in Greenwich Mean Time.
// However, go asn1/marshal will happily accept other formats. So we force it directly here.
// https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.5.2
Time: time.Now().UTC(),
Nonce: req.Nonce,
Policy: policyID,
Ordering: false,
Expand Down
3 changes: 3 additions & 0 deletions pkg/tests/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ func TestGetTimestampResponse(t *testing.T) {
if tsr.Time.After(time.Now()) {
t.Fatalf("test '%s': expected time to be set to a previous time", tc.name)
}
if tsr.Time.Location() != time.UTC {
t.Fatalf("test '%s': expected time to be in UTC, got %v", tc.name, tsr.Time.Location())
}
duration, _ := time.ParseDuration("1s")
if tsr.Accuracy != duration {
t.Fatalf("test '%s': expected 1s accuracy, got %v", tc.name, tsr.Accuracy)
Expand Down

0 comments on commit 793b720

Please sign in to comment.