@@ -12,6 +12,7 @@ import (
1212
1313 "github.com/Sirupsen/logrus"
1414 "github.com/docker/go/canonical/json"
15+ "github.com/docker/notary"
1516)
1617
1718// SigAlgorithm for types of signatures
@@ -171,16 +172,16 @@ func NewDelegations() *Delegations {
171172 }
172173}
173174
174- // defines number of days in which something should expire
175- var defaultExpiryTimes = map [string ]int {
176- CanonicalRootRole : 365 ,
177- CanonicalTargetsRole : 90 ,
178- CanonicalSnapshotRole : 7 ,
179- CanonicalTimestampRole : 1 ,
175+ // These values are recommended TUF expiry times.
176+ var defaultExpiryTimes = map [string ]time. Duration {
177+ CanonicalRootRole : notary . Year ,
178+ CanonicalTargetsRole : 90 * notary . Day ,
179+ CanonicalSnapshotRole : 7 * notary . Day ,
180+ CanonicalTimestampRole : notary . Day ,
180181}
181182
182183// SetDefaultExpiryTimes allows one to change the default expiries.
183- func SetDefaultExpiryTimes (times map [string ]int ) {
184+ func SetDefaultExpiryTimes (times map [string ]time. Duration ) {
184185 for key , value := range times {
185186 if _ , ok := defaultExpiryTimes [key ]; ! ok {
186187 logrus .Errorf ("Attempted to set default expiry for an unknown role: %s" , key )
@@ -192,10 +193,10 @@ func SetDefaultExpiryTimes(times map[string]int) {
192193
193194// DefaultExpires gets the default expiry time for the given role
194195func DefaultExpires (role string ) time.Time {
195- var t time.Time
196- if t , ok := defaultExpiryTimes [role ]; ok {
197- return time .Now ().AddDate (0 , 0 , t )
196+ if d , ok := defaultExpiryTimes [role ]; ok {
197+ return time .Now ().Add (d )
198198 }
199+ var t time.Time
199200 return t .UTC ().Round (time .Second )
200201}
201202
0 commit comments