Skip to content

Commit

Permalink
handle AKV key name collision
Browse files Browse the repository at this point in the history
  • Loading branch information
shueybubbles committed Aug 31, 2023
1 parent 4137aa2 commit 7a47b91
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/akvkeys/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ func CreateRSAKey(client *azkeys.Client) (name string, err error) {
Kty: &kt,
KeySize: &ks,
}
i, _ := rand.Int(rand.Reader, big.NewInt(1000))

i, _ := rand.Int(rand.Reader, big.NewInt(1000000))
name = fmt.Sprintf("go-mssqlkey%d", i)
_, err = client.CreateKey(context.TODO(), name, rsaKeyParams, nil)
if err != nil {
_, err = client.RecoverDeletedKey(context.TODO(), name, &azkeys.RecoverDeletedKeyOptions{})
}
return
}

Expand Down

0 comments on commit 7a47b91

Please sign in to comment.