While Fox News has cemented itself as a cheerleader for President Donald Trump, its star legal analyst trashed the commander in chief for defending former national security adviser Michael Flynn after it became known that he lied to the feds.

“The message is the president ought to have known what Michael Flynn was up to at the time,” Andrew Napolitano said on the network Tuesday. “The president is, so far, the loser in all this,” the former judge added, noting that Trump “has minimized what Gen. Flynn has done.”

Flynn is due to be sentenced next year for making false statements to the FBI regarding his contact with Russian officials, which is pertinent to special counsel Robert Mueller’s probe of meddling in the 2016 U.S. election.

However, Trump offered his support for the disgraced Flynn on Twitter, wishing him good luck on Tuesday ahead of his court appearance and claiming his former adviser was being placed under “tremendous pressure.”

Good luck today in court to General Michael Flynn. Will be interesting to see what he has to say, despite tremendous pressure being put on him, about Russian Collusion in our great and, obviously, highly successful political campaign. There was no Collusion! — Donald J. Trump (@realDonaldTrump) December 18, 2018

When it comes to the Flynn case, Trump’s social media habit is one he needs to kick, Napolitano suggested, slamming the president for attempting to tamp down concerns over the former aide.

“Maybe he could have tweeted at the time Gen. Flynn was arrested, but he now knows what Flynn was doing at the time, so he shouldn’t be minimizing it,” Napolitano said. “Gen. Flynn was a foreign agent while he was working in the White House and he kept that from his bosses. That is not light or easy or something to be tweeted about or made a joke of.”

(While the judge in Flynn’s case initially said he was a foreign agent while he was in the White House, he later corrected himself and noted Flynn had stopped his work as a foreign agent for Turkey before his stint as national security adviser.)

Trump faced a wave of backlash online for expressing support for Flynn, as people on Twitter voiced shock that he would send such a message to the ousted official in light of his guilty plea.

U.S. District Judge Emmet G. Sullivan was far less sympathetic than the president. He told Flynn Tuesday, “arguably, you sold your country out,” noting that his crime was serious and could be punished with jail time.

This story has been updated to include additional information about Judge Sullivan’s comments.