Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/asn1: Unmarshal accepts negative dates #11134

dvyukov opened this issue Jun 9, 2015 · 1 comment

encoding/asn1: Unmarshal accepts negative dates #11134

dvyukov opened this issue Jun 9, 2015 · 1 comment


Copy link

@dvyukov dvyukov commented Jun 9, 2015

The following program:

package main

import (

func main() {
    data := []byte("\x18\x0f00000100000000Z")
    var v time.Time
    _, err := asn1.Unmarshal(data, &v)
    if err != nil {
    _, err = asn1.Marshal(v)
    if err != nil {

panics with:

-0001-12-31 00:00:00 +0000 UTC
panic: asn1: structure error: cannot represent time as GeneralizedTime

The value is successfully unmarshalled, but can't be marshalled. I am not sure who exactly is wrong here. This happens because of "date normalization" in time package, it converts day 0 to the last day of the previous month. ASN.1 (ISO 8601) does not define "date normalization", if I understand correctly, assuming that dates and times are valid as is.

I think we should not do time/date normalization, because it is asking for troubles security-wise.

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jun 10, 2015
Copy link

@gopherbot gopherbot commented Jun 14, 2015

CL mentions this issue.

@agl agl closed this in fdd921c Jun 29, 2015
@mikioh mikioh modified the milestones: Go1.5, Go1.6 Jun 29, 2015
@golang golang locked and limited conversation to collaborators Jun 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.