Now, a Common Pleas Court judge has been asked to decide whether that agreement existed and, if it did, whether it protects Cosby from the three counts of aggravated indecent assault filed against him last month.
Cosby's lawyers have suggested that Castor will be a key defense witness at a Feb. 2 hearing at which they hope to have the case against Cosby thrown out. Castor's email, sent three months before the counts against the comedian were filed, mirrors arguments they made in court filings last week.
The email could also offer a preview of what Castor is likely to say if called to testify. But whether his testimony could derail the criminal case against Cosby remains to be seen.
Montgomery County District Attorney Kevin Steele - who defeated Castor last fall after criticizing him for his handling of the Cosby case in 2005 - has said there is no evidence of a legally binding immunity agreement. Steele has previously described such arguments as "revisionist history."
"We'll be filing a response," Steele said Saturday. "We will litigate this in court."
Legal experts characterized the role Castor describes for himself in the email - granting a verbal non-prosecution agreement in order to help one side in a civil case - as an unusual one for a prosecutor.
L. George Parry, a former federal prosecutor in Philadelphia, questioned why Cosby's lawyers would send their client to be deposed in a civil suit without a formal immunity deal.
"I've just never heard of a verbal side deal like what this guy is describing," he said. "Any defense lawyer who would enter into a verbal agreement like this without getting it in writing and signed by the District Attorney would have to have rocks in his head."
Cosby's criminal lawyer in 2005 - Walter M. Phillips Jr. - died in February.
In his September email, Castor was resolute. He declined to comment Saturday.
"Unless you can make out a case without that deposition and without anything that deposition led you to, I think Cosby would have an action against the County and maybe even you personally," he wrote to Ferman in the message, which was first reported Friday by CNN.
At the time, Castor was locked in a contentious political race to reclaim his old office against Steele, Ferman's former first assistant. And though Steele had not yet begun airing TV ads criticizing Castor's handling of the Cosby case, Castor told The Inquirer at the time that he believed his opponent was using the Cosby investigation as a campaign issue to help win the election.
In his message to Ferman, Castor explained his decision not to prosecute Cosby in 2005, when Constand first came forward alleging that the comedian had drugged and assaulted her at his Cheltenham mansion a year earlier.
Castor said that given a lack of credible evidence to back up Constand's assertions, he agreed, in conjunction with Cosby's and Constand's lawyers, that criminal charges would not be filed.
"With the agreement of the defense lawyer and Andrea's lawyers, I intentionally and specifically bound the Commonwealth that there would be no state prosecution of Cosby in order to remove from him the ability to claim his Fifth Amendment protection against self incrimination thus forcing him to sit for a deposition under oath," Castor wrote in the email.
Constand attorney Dolores Troiani has said that Castor never consulted her about any deal protecting Cosby from prosecution and that even if he had, her client would never have agreed to it. Constand is suing Castor for defamation.
In July, a federal judge unsealed for the first time portions of Cosby's 2005 deposition in Constand's civil case.
In them, Cosby detailed a number of romantic overtures he made to her and said that he gave her wine and pills the night she alleges she was assaulted. He maintained throughout the deposition that she consented to their sexual encounter.
It remains unclear how much the deposition factors into prosecutors' current criminal case, though they have said its unsealing was what prompted them to revive their investigation.
Cosby, 78, has denied assaulting Constand or any of the dozens of other women who have made similar allegations in the years since she came forward.
He remains free pending his trial on a $1 million bond. If convicted on a charge of aggravated indecent assault, he faces up to 10 years in prison.