The childhood friend of Dzhokhar Tsarnaev who admitted he unknowingly put the gun used to murder MIT Police Officer Sean Collier in the Boston Marathon bomber’s hands was ordered set free today by a federal judge after spending the past 17 months in prison.

“You got a gun and you gave it to your friend, and, as a result, a police officer is dead. That is part of your history and characteristics, and will be for the rest of your life,” U.S. District Court Judge Mark L. Wolf told Stephen Silva, 22, at his sentencing.

“I’m very sorry for that,” Silva blurted out, even after he’d finished reading his apology “for my actions” from a folded piece of paper as he stood clad in a tan jailhouse jumpsuit.

The convicted drug dealer, calling his misery “self-inflicted,” told Wolf , “I was young and dumb,” but that he is now “truly remorseful and sorry for my actions.”

Silva was facing up to five years in a federal penitentiary, but appealed to Wolf, “Your Honor, I’m pleading for a second chance.”

Collier, 27, was shot and killed by the Tsarnaev brothers April 18, 2013, as they were fleeing authorities closing in to arrest them for the deadly Boston Marathon bombings three days earlier.

Silva testified for the government that Tsarnaev, 22, asked to borrow the Ruger P95 two months earlier to rob some drug dealers at the University of Rhode Island, but never gave it back.

Assistant U.S. Attorney Peter K. Levitt assured Wolf today that Silva was a “credible and important” witness, who from the “first day” of his arrest last year was willing to cooperate against his pal, even at great risk to his own life.

“The defendant has taken significant risk in cooperating in a case that has received international attention,” Levitt said. “His name is connected to that case for better or worse.”

Silva previously pleaded guilty to charges of heroin distribution and possession of an illegal firearm with an obliterated serial number.

The Ruger was recovered at the scene of the Watertown shootout between police and the Tsarnaev brothers that ended with the death of Tamerlan Tsarnaev.