The top US defence officer has said an order from President Donald Trump or any of his successors to launch nuclear weapons can be refused if that order is determined to be illegal.

Air Force General John Hyten, commander of US Strategic Command, told a panel at the Halifax International Security Forum that he and Mr Trump have had conversations about such a scenario and that he would tell Mr Trump he could not carry out an illegal strike.

"If it's illegal, guess what's going to happen. I'm going to say, 'Mr President, that's illegal'. And guess what he's going to do? He's going to say, 'What would be legal?'" Gen Hyten said.

"And we'll come up with options with a mix of capabilities to respond to whatever the situation is, and that's the way it works."

In the event that Mr Trump decided to launch a nuclear attack, Gen Hyten would provide him with strike options that are legal.

The command would control nuclear forces in a war.

The comments come as the threat of nuclear attack from North Korea remains a serious concern and Mr Trump's critics question his temperament.

Mr Trump's taunting tweets aimed at Pyongyang have sparked concerns primarily among congressional Democrats that he may be inciting a war with North Korea.

During testimony before the Foreign Relations Committee earlier this month, retired General Robert Kehler, who served as the head of Strategic Command from January 2011 to November 2013, also said the US armed forces are obligated to follow legal orders, not illegal ones.

Gen Hyten said he has talked it over with Mr Trump.

"I think some people think we're stupid. We're not stupid people. We think about these things a lot. When you have this responsibility, how do you not think about it?,' he said.

He said he would not obey an illegal order.

"You could go to jail for the rest of your life," he said.

AP