keycard-generate-key doesn't overwrite an existing key

This commit is contained in:
Andrea Franz 2019-04-03 11:56:33 +02:00
parent e82334eb54
commit 1025cd3f48
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
1 changed files with 13 additions and 0 deletions

View File

@ -557,6 +557,19 @@ func (s *Shell) commandKeycardGenerateKey(args ...string) error {
return err return err
} }
logger.Info("get status before generating key")
appStatus, err := s.kCmdSet.GetStatusApplication()
if err != nil {
logger.Error("get status failed", "error", err)
return err
}
if appStatus.KeyInitialized {
err = errors.New("key already generated. you must delete it before creating a new one")
logger.Error("generate key failed", "error", err)
return err
}
logger.Info("generate key") logger.Info("generate key")
keyUID, err := s.kCmdSet.GenerateKey() keyUID, err := s.kCmdSet.GenerateKey()
if err != nil { if err != nil {