mirror of
https://github.com/golang/go.git
synced 2024-09-29 14:26:50 +00:00
encoding/asn1: handle UTCTime before the year 2000
UTCTime only has a two digit date field and year values from 50 should be 1950, not 2050. R=golang-dev, r, rsc CC=golang-dev https://golang.org/cl/5729063
This commit is contained in:
parent
d5f78d77c0
commit
6aed613030
@ -250,10 +250,14 @@ func parseBase128Int(bytes []byte, initOffset int) (ret, offset int, err error)
|
||||
func parseUTCTime(bytes []byte) (ret time.Time, err error) {
|
||||
s := string(bytes)
|
||||
ret, err = time.Parse("0601021504Z0700", s)
|
||||
if err == nil {
|
||||
return
|
||||
if err != nil {
|
||||
ret, err = time.Parse("060102150405Z0700", s)
|
||||
}
|
||||
ret, err = time.Parse("060102150405Z0700", s)
|
||||
if err == nil && ret.Year() >= 2050 {
|
||||
// UTCTime only encodes times prior to 2050. See https://tools.ietf.org/html/rfc5280#section-4.1.2.5.1
|
||||
ret = ret.AddDate(-100, 0, 0)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user