Of course typically (in the bluebeard era) pirates actually did have a charter, or really a Letter of Marque from the crown. One country's "pirate" was another country's outsourced naval agent. This was true also in the barbary states (hence the song of the US marines) and the straights of malacca et al.
The ones today in the horn of africa though, AFAIK, are indeed free agents.