Add an implicitly tagged field to a struct of type time.Time and tagged it with "generalized". Marshalled the struct and then unmarshalled it. Unmarshalling failed because it parses the time as a UTCTime.
Unmarshalling observe the "generalized" attribute tag and parse the time as a Generalized Time
What did you see instead?
Unmarshalling parsed the time as a UTCTime which failed and produced the zero val for the time.
Looking at the current test suite, it appears that the implementation of the "generalized" attribute tag is incomplete:
func TestImplicitTaggedTime(t *testing.T) {
// An implicitly tagged time value, that happens to have an implicit
// tag equal to a GENERALIZEDTIME, should still be parsed as a UTCTime.
// (There's no "timeType" in fieldParameters to determine what type of
// time should be expected when implicitly tagged.)
der := []byte{0x30, 0x0f, 0x80 | 24, 0xd, '9', '1', '0', '5', '0', '6', '1', '6', '4', '5', '4', '0', 'Z'}
var result implicitTaggedTimeTest
if _, err := Unmarshal(der, &result); err != nil {
t.Fatalf("Error while parsing: %s", err)
}
if expected := time.Date(1991, 05, 06, 16, 45, 40, 0, time.UTC); !result.Time.Equal(expected) {
t.Errorf("Wrong result. Got %v, want %v", result.Time, expected)
}
}
But there IS a timeType set by the use of the "generalized" tag.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Add an implicitly tagged field to a struct of type time.Time and tagged it with "generalized". Marshalled the struct and then unmarshalled it. Unmarshalling failed because it parses the time as a UTCTime.
https://play.golang.org/p/XOKSctdaYl5
What did you expect to see?
Unmarshalling observe the "generalized" attribute tag and parse the time as a Generalized Time
What did you see instead?
Unmarshalling parsed the time as a UTCTime which failed and produced the zero val for the time.
Looking at the current test suite, it appears that the implementation of the "generalized" attribute tag is incomplete:
But there IS a timeType set by the use of the "generalized" tag.