A U.S. appeals court on Tuesday upheld the 25-year prison sentence of an Idaho man who fired a rifle at the White House in 2011.

The U.S. Court of Appeals for the District of Columbia Circuit found that Oscar Ramiro Ortega-Hernandez had waived his right to challenge the length of the sentence when he pleaded guilty in 2013.

Ortega-Hernandez, of Idaho Falls, Idaho, fired at least eight rounds at the White House using a semi-automatic rifle.

President Barack Obama and his wife Michelle were not in Washington at the time, and no one was hurt.

Ortega-Hernandez shot from his car and then fled, according to prosecutors. He was later arrested about 200 miles away in Pennsylvania.

Prosecutors said Ortega-Hernandez was motivated by hatred for Obama. Defense lawyers called him a confused, desperate man who shot at the White House to draw attention to what he thought was an impending Armageddon.

The appeals court did find in Ortega-Hernandez's favor on one technical point. The district judge had incorrectly said that Ortega-Hernandez should register as a sex offender, the three-judge panel said.