I remember that episode in The Flash. Barry could have cleared his name by revealing his secret identity to give an alibi for where he was when DeVoe's body was found. But no. He just had to discover a new power when Iris tried to out him in court and froze her in time to tell her not to reveal his secret because of the target on their backs when every villain knows, even though every season-long villain including DeVoe already knew Barry's identity anyway. Reverse-Flash and Zoom had been moles on Team Flash. Savitar was a future version of Barry. And DeVoe figured it out as soon as Barry confronted him. What's a few more criminals finding out Barry's identity from a trial when his most dangerous foes would know him anyway? Oh wait, this isn't the same episode. Barry had to spend a couple episodes in Iron Heights because he chose not to tell the truth that would have set him free.
And also, my Killer Bees does this trick constantly to get away with murder because they have two Norks in the gang. But because the female Nork, Tina has revealed that in her exposition dump to Rubber Girl who had told Fairy Girl about that, they were able to expose them in the trial for the murder of Sasha Fair.
So because this was a plot point in the Arrowverse making a hero too stubborn about his secret identity, and this is how the villains of my fourth book avoided getting caught, I really don't want this to be the ending of Peter's trial. What I hope for the ending is Matt Murdock convincing the jury that Spider-Man is not guilty of murder.
And of course, Peter would not have to ask Strange for a spell for people to forget he's Spider-Man if his secret identity was already closed back up in the trial.