-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: JuliannaReyes <[email protected]>
- Loading branch information
1 parent
7b85661
commit 6963b4d
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/flynn/go-docopt" | ||
"github.com/theupdateframework/go-tuf" | ||
|
||
|
||
) | ||
func init() { | ||
register("remove-key", cmdRemoveKey, ` | ||
usage: tuf remove-key [--expires=<days>] <role> <id> | ||
Remove a signing key | ||
Before the key is removed the key will be first revoked | ||
The key will then be removed from the root metadata file and if the key is present in | ||
"keys" directory it will also be removed | ||
Options: | ||
--expires=<days> Set the root metadata file to expire <days> days from now. | ||
`) | ||
} | ||
|
||
func cmdRemoveKey(args *docopt.Args, repo *tuf.Repo) error { | ||
role := args.String["<roles>"] | ||
keyID := args.String["<id>"] | ||
if err := repo.RevokeKey(role, keyID); err != nil{ | ||
return err | ||
} | ||
keyPath := filepath.Join("keys", keyID) | ||
if _ , err := os.Stat(keyPath); err==nil{ | ||
if err := os.Remove(keyPath); err != nil{ | ||
return err | ||
} | ||
} | ||
return nil | ||
} |