No officer, by color of office, shall take any obligation, otherwise than is directed by law, of or for any person in custody. If does the same shall be void.