Skip to content

Commit

Permalink
[Delegations prereq] Support delegated targets in DefaultExpires and …
Browse files Browse the repository at this point in the history
…fix GenKey expiration (#202)

Splitting up #175
  • Loading branch information
ethan-lowman-dd authored Jan 11, 2022
1 parent cced2c6 commit ab254c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions data/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ func DefaultExpires(role string) time.Time {
switch role {
case "root":
t = time.Now().AddDate(1, 0, 0)
case "targets":
t = time.Now().AddDate(0, 3, 0)
case "snapshot":
t = time.Now().AddDate(0, 0, 7)
case "timestamp":
t = time.Now().AddDate(0, 0, 1)
default:
// targets and delegated targets
t = time.Now().AddDate(0, 3, 0)
}
return t.UTC().Round(time.Second)
}
Expand Down
2 changes: 1 addition & 1 deletion repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func (r *Repo) ChangePassphrase(keyRole string) error {
}

func (r *Repo) GenKey(role string) ([]string, error) {
return r.GenKeyWithExpires(role, data.DefaultExpires("root"))
return r.GenKeyWithExpires(role, data.DefaultExpires(role))
}

func (r *Repo) GenKeyWithExpires(keyRole string, expires time.Time) (keyids []string, err error) {
Expand Down

0 comments on commit ab254c0

Please sign in to comment.