mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-09 08:01:31 +00:00
cmd/tailscale,tka: make KeyID return an error instead of panicking
Signed-off-by: Tom DNetto <tom@tailscale.com>
This commit is contained in:
@@ -60,7 +60,12 @@ func (b *UpdateBuilder) mkUpdate(update AUM) error {
|
||||
|
||||
// AddKey adds a new key to the authority.
|
||||
func (b *UpdateBuilder) AddKey(key Key) error {
|
||||
if _, err := b.state.GetKey(key.ID()); err == nil {
|
||||
keyID, err := key.ID()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := b.state.GetKey(keyID); err == nil {
|
||||
return fmt.Errorf("cannot add key %v: already exists", key)
|
||||
}
|
||||
return b.mkUpdate(AUM{MessageKind: AUMAddKey, Key: &key})
|
||||
|
Reference in New Issue
Block a user