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

Splitting up #175
  • Loading branch information
ethan-lowman-dd committed Dec 10, 2021
1 parent c2bc1c1 commit 8699d1f
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 8699d1f

Please sign in to comment.