Skip to content

Commit fd2b1e2

Browse files
bavis-mroot
authored and
root
committed
OpenSSL can generate timestamps in index.txt with 4 digits for the year, so support that format in ReadCerts
1 parent f3164cd commit fd2b1e2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Diff for: lib/certificates.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,19 @@ func ReadCerts(path string) ([]*Cert, error) {
5353
fmt.Errorf("incorrect number of lines in line: \n%s\n. Expected %d, found %d",
5454
line, 6, len(fields))
5555
}
56-
expT, _ := time.Parse("060102150405Z", fields[1])
56+
layout := "060102150405Z"
57+
if len(fields[1]) == len(layout) + 2 {
58+
layout = "20060102150405Z"
59+
}
60+
expT, _ := time.Parse(layout, fields[1])
5761
expTA := time.Now().AddDate(0, 0, 30).After(expT) // If cer will expire in 30 days, raise this flag
5862
//logs.Debug("ExpirationT: %v, IsExpiring: %v", expT, expTA) // logging
59-
revT, _ := time.Parse("060102150405Z", fields[2])
63+
64+
layout = "060102150405Z"
65+
if len(fields[1]) == len(layout) + 2 {
66+
layout = "20060102150405Z"
67+
}
68+
revT, _ := time.Parse(layout, fields[2])
6069
c := &Cert{
6170
EntryType: fields[0],
6271
Expiration: fields[1],

0 commit comments

Comments
 (0)