If a country feels threatened, it can prohibit the passage of warship in its water. It is the international law. Iran would only bock the strait to oil if there is an embargo on its own oil.
200 feared dead in latest migrant disaster off Libya's coast (AP)
from the article: Obama secretly warns Iran against closing Strait of Hormuz, report says