Notwithstanding any other provision of law, upon a request made in writing to a public entity, the public entity may defend or indemnify or defend and indemnify any witness who has testified on behalf of the public entity in any criminal, civil, or administrative action. The decision of the public entity to defend or indemnify or defend and indemnify such a witness shall rest within the sound discretion of the public entity and may be based on any relevant factors, including, but not limited to, whether the provision of defense or indemnity would serve the public interest. The public entity may defend or indemnify or defend and indemnify the witness only if it is determined by the public entity that the action being brought against the witness is based directly upon the conduct which the public entity requested of the witness related to the witness' testimony or provision of evidence. The public entity has the discretion to provide a defense alone apart from indemnity, and the public entity may offer to defend or indemnify or defend and indemnify while reserving all rights to subsequently withdraw these offers upon reasonable notice.
Neither defense nor indemnification shall be provided if the testimony giving rise to the action against the witness was false in any material respect, or was otherwise not given by the witness with a good faith belief in its truth; nor shall representation or indemnification under this section be offered or promised unless the action has been commenced and the witness has requested the public entity to act for the witness' benefit under this section. The public entity shall not be liable for indemnification of a defendant witness for punitive damages awarded to the plaintiff in such an action. If the plaintiff prevails in a claim for punitive damages in an action defended at the expense of the public entity, the defendant shall be liable to the public entity for the full costs incurred by the public entity in providing representation to the defendant witness.
Ca. Gov. Code § 995.9