Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/asn1: valid GeneralizedTime not parsed #15842
Please answer these questions before submitting your issue. Thanks!
Note that the data is 3rdparty, I have no control over it. I see that golang asn1 disclames limited support. I am curious what are my options to workaround the issue - is it just a fork of the original library or there are other ways to hook my own parser for the GeneralizedTime?
We don't use the issue tracker for questions. Please https://golang.org/wiki/Questions . I don't know the answer to this, but I think you just need to unmarshal into a string and parse the time yourself. It doesn't seem like a bug, so I'm going to close this. Please comment if you think this is a bug that needs to be fixed in the Go standard library.
A valid GeneralizedTime is rejected. Even disclaimed as limitation it is still a good thing to keep request to fix it open, I think.
The way the asn1 is organised (it encodes the type in the serialised data) it is not possible to interpret the data as something else without changing the package ... and as I already said it is provided from 3rdparty in my case.
It is probably a good idea asn1 to offer a mechanism a customer defined parser to be hooked instead of the internal ones. There might be other cases where replacement is desirable/needed.
changed the title from
how to work around asn1 support limitation of parsing GeneralizedTime
encoding/asn1: valid GeneralizedTime not parsed
May 26, 2016
This seems as reliable source for what are the valid GeneralizedTime format(s) http://www.obj-sys.com/asn1tutorial/node14.html
I will copy the content just in case the link is dropped.
Type GeneralizedTime takes values of the year, month, day, hour, time, minute,second, and second fraction in any of three forms.
Local time only.
then any of the following three values of CurrentTime are valid:
I have stumbled across this when using the Go package github.com/digitorus/timestamp with the RFC3161 Time Stamping Authority freetsa.org, which encodes GeneralizedTimes like 20180329224911.41882Z into their responses (up to six fractional digits). These ASN1 objects with fractional digits will be decoded fine with
The restriction to three fractional digits, which is suggested in the tutorial at the obj-sys.com page linked in the comment above, doesn't appear in the ITU documents:
See also the section in RFC3161 starting with
From my point of view the fix would be to change the format string
referenced this issue
Apr 17, 2018
What is going on with this strange language Go? The issue is here for two years, fix is ready, but the real mistake was not fixed in latest 1.11 Go source. Who is responsible for all this stack of garbage named Go? Can anyone introduce the fix in main Go code and prevent me from fixing main source code of Go locally?