Browse Source

Check EAB key exists before deleting it

Herman Slatman 5 years ago
parent
commit
a1afbce50c
1 changed files with 6 additions and 2 deletions
  1. 6 2
      acme/db/nosql/account.go

+ 6 - 2
acme/db/nosql/account.go

@@ -222,9 +222,13 @@ func (db *DB) GetExternalAccountKey(ctx context.Context, provisionerName string,
 }
 
 func (db *DB) DeleteExternalAccountKey(ctx context.Context, keyID string) error {
-	err := db.db.Del(externalAccountKeyTable, []byte(keyID))
+	_, err := db.db.Get(externalAccountKeyTable, []byte(keyID))
 	if err != nil {
-		return errors.Wrapf(err, "error deleting ACME EAB Key with Key ID: %s", keyID)
+		return errors.Wrapf(err, "error loading ACME EAB Key with Key ID %s", keyID)
+	}
+	err = db.db.Del(externalAccountKeyTable, []byte(keyID))
+	if err != nil {
+		return errors.Wrapf(err, "error deleting ACME EAB Key with Key ID %s", keyID)
 	}
 	return nil
 }