A former police officer has been jailed for more than five years after being "caught red handed" trying to buy an untraceable gun on the "dark web".
Allan Kennedy, 31, whose address was given as Strandtown police station, admitted possessing a 9mm pistol, 10 rounds of 9mm ammunition and a silencer with intent to endanger life.
The defendant was described as a "low-level community drug dealer" in court.
It heard that he bought the gun for his own protection.
Kennedy also pleaded guilty to a string of other offences.
These included possession of cocaine with intent to supply and perverting the course of justice.
Kennedy, who was a serving police officer at the time of the offences, admitted possessing 30g of cocaine, 50 diazepam tablets and 10g of class C amphetmines at a house in Newtownards, County Down.
He also admitted perverting the course of justice by crashing his car in March 2014 in Bangor, County Down, before deliberately setting it on fire.
The police said the conviction showed the PSNI's "commitment to keep drugs and firearms off the streets of Northern Ireland".
"Those intent on criminal activity should know that even with the perceived anonymity of activity on the 'dark web', we will continue to pursue criminals in whatever quarter they operate to keep people safe," said Det Ch Insp Michael Harvey, from the PSNI's cyber crime centre.
The judge sentenced Kennedy to five-and-a-half years in prison followed by five-and-a-half years on licence.
Passing sentence at Downpatrick Crown Court, the judge said the charge of perverting the course of justice alone could attract a life sentence.
He said he was satisfied that Kennedy had told "lie after lie" to evade responsibility for what he had done, by claiming his car had been stolen before being set alight.
The judge added that the case was aggravated by Kennedy's job as a serving police officer at the time.
He said that Kennedy's attempt to purchase the gun two years after his first offence was in the context of his drug dealing activity.
"You intended to purchase it ready for use if, and when, the occasion arose," the judge said.
"It is accepted that you were a user of class A drugs and were supplying others in order to feed your habit.
"It is accepted you should be treated as a commercial supplier of drugs."
The judge rejected the defendant's claims that he wanted to purchase the gun and silencer to end his own life due to the approaching court case for perverting the course of justice.
Undercover police sting
He said this "did tie in" with the fact that Kennedy was purchasing 10 rounds of ammunition with the weapon, which he had specifically requested to be "clean and untraceable".
The judge said he was obliged to impose a "punitive sentence" because of the "insidious and corrosive impact" such weapons have on the community.
The court previously heard that Kennedy, a self-confessed cocaine addict, was unaware he was dealing with undercover police when trying to buy the gun on the "dark web".
Following an exchange of messages and pictures of the gun, an undercover officer arranged for a meeting and handover of the gun.
In September 2015, Kennedy met another undercover officer in Belfast to discuss the gun and the silencer.
Kennedy placed £260 in a folded newspaper on the table, which the officer took.
The court heard that it was arranged that the handover of the gun would take place later that day in the Annadale Embankment area.
The officer then met Kennedy at the location, opened the boot of his car and handed over a package that contained the gun, which had been stripped down.
The court heard that Kennedy then handed over a further sum of £240.
Police then converged on the scene and arrested Kennedy.
During follow up searches of the defendant's car, cocaine and other drugs were found.
Dealer bags and mobiles containing text messages associated with someone involved in supplying narcotics were also seized.
Two properties were then raided as part of the investigation.
In one bedroom where Kennedy stayed, police found quantities of ecstasy and cannabis, more drug-related paraphernalia, price lists and documents linked to the use of the "dark web".
The seized drugs had a total street value of up to £10,000.
Police also uncovered 50 rounds of 9mm ammunition, which were described in court as "dum dum" bullets that are more liked to be used in "big game hunting".
Kennedy's defence lawyer said he was remorseful for his actions and accepted he faced a "substantial custodial sentence".
"There is no real risk of action harm to the public as the person he was trying to buy the gun off was an undercover police officer," he said.
The defence lawyer said Kennedy's life went into a "downward spiral" when he was struck by a stolen car while on duty and spent six months on sick leave after sustaining a fractured foot.
He added that Kennedy was now addressing his cocaine addiction through "one-to-one counselling sessions" in prison.