Charges of possessing extreme pornography are enough to destroy any man. When the Crown Prosecution Service added the allegation that the pornography included an image of child abuse, Simon Walsh's disgrace seemed complete. He was a barrister, a City of London alderman, a magistrate and one of Boris Johnson's appointees on the London Fire Authority. The mention of paedophile porn, and gay porn at that, sent these venerable institutions running.

I know it is hopeless to seek to dent Boris Johnson's self-portrait of a carefree British patriot in this moment of Olympic euphoria, but it's all an act. In the 1930s, a journalist confronted Brendan Bracken, Churchill's bumptious sidekick, and bellowed: "You're phoney! Everything about you is phoney! Even your hair that looks like a wig – isn't!" Bracken had a mop of red hair to match Johnson's mop of blond. If Johnson were a true, plain-speaking patriot, he would have stood by Britain's best principle that a citizen is innocent until proven guilty. But he is a phoney, and his officials fired Walsh without a second's thought. The best that can be said of London's mayor is that he did not behave as badly as Walsh's colleagues. His fellow magistrates bailed him on condition he stayed at a house where he had not lived for 18 months. Walsh had to sleep on its floor. His fellow barristers at London's 5 Essex Court Chambers forgot everything they had learned about the presumption of innocence, and asked the police to seize his pass so that he could not re-enter their offices.

The Crown Prosecution Service under the current director of public prosecutions, Keir Starmer, is earning a deservedly bad reputation for its vexatious litigation. Her Majesty's chief inspector estimates that almost one in 10 of its prosecutions is baseless Thousands of people plead guilty, nevertheless, just to get the CPS off their backs.

Thirty years ago, the homosexual element in the affair would have made Walsh cop a plea and slink away into obscurity. But Walsh is an openly gay man in the 21st century. "I've never hidden what I am," he told me. "I knew I had done nothing wrong and was not going to run away."

Like Paul Chambers, who took on the CPS when it tried to punish him for making a joke on Twitter, Walsh fought back. The "extreme pornography" the CPS described to the court sounded suitably obscene. The police found five images on Walsh's computer of anal fisting – which speaks for itself – and of "urethral sounding" – which I probably need to inform you involves the insertion of surgical rods into the penis. Three of the photographs, however, turned out to be of Walsh and his gay friends, who took pictures of each other engaging in consensual and legal sex.

More ominously for those who believe that the CPS is an honourable institution, the picture it claimed showed child abuse showed nothing of the sort. One expert witness for the prosecution, a 74-year-old retired GP the Metropolitan Police had travelled all the way to Manchester to find, claimed it was a teenage boy.

Witnesses for the defence said it was a man in his 20s. They were backed up by the story in the email that accompanied the picture, which also said the naked man was in his mid-20s. The prosecution was not able to prove that Walsh had requested the message or even clicked on the image.

The poor old jurors had a lot to put up with, what with one thing and another – the prosecution passing them implements for sticking down penises and an expert witness explaining: "It may take some time for someone to take a whole arm into their rectum."

But, unlike Boris Johnson, they knew that what consenting adults did with their johnsons was no business of the state. The jury concluded that, however obscene the sexual practices on display, they were not as obscene as the notion that the CPS could poke its nose into the nation's bedrooms. It acquitted and proved that the ruin of Simon Walsh's career, the costs of a case that had forced him to sell his flat and the public money spent on bringing him to trial had been a colossal waste.

You, dear reader, should be worried. The supposed child pornography was lying unopened in a file in one of Walsh's inboxes. Are you sure there is nothing similar in a spam folder on your laptop?

If there is, you many face prosecution under an obscenity law that ignores John Stuart Mill's principle that consenting adults must be free to do as they choose as long as they do not harm others.

"I thought the CPS was meant to stop nasty exploitative porn," said Walsh, "but it is punishing snaps friends take of each other in their own homes."

The catch-all nature of obscenity law is scarcely an exception. The Communications Act used to prosecute Paul Chambers covers any message that is grossly offensive, indecent, obscene or menacing. Hundreds of thousands of people have sent emails, tweets or Facebook messages that fall within its terms.

When the law can punish everyone, the question arises: why does the CPS use it to prosecute someone? Contrary to Mill's maxim, the CPS says it was right to prosecute because the possession of images of acts likely to cause serious injury is illegal, even if they are consensual.

Myles Jackman, Walsh's solicitor, does not believe it, any more than the jury did. In this as in so many other cases, the CPS charged Walsh to save face, he says. The police had been convinced that Walsh was part of a child porn ring. Met officers put their reputations on the line by securing the approval of a district assistant commissioner, the commissioner of the City of London police and the lord mayor of London to raid Walsh's home.

A dozen detectives made a great scene when they tore to his flat in two vans. They even interviewed Walsh's goddaughters and asked if he had abused them. They found no evidence of a paedophile ring, so used what little they could find on Walsh's computer to damn him instead

If you receive the same treatment, you should remember that liberty in Britain has not advanced because of revolutions or stirring proclamations on continental lines.

Liberty has advanced because bloody-minded protesters such as Chambers and Walsh have ignored cautionary voices, dug in their heels and fought until they forced capricious authority to back down.