If a sentence was passed or process issued by a court having jurisdiction under any circumstances to pass such a sentence or to issue such a process, or if a warrant was issued by a court or justice or other person having authority under any circumstances to issue such a warrant, it is immaterial whether the court or justice or person had or had not authority to pass the sentence or issue the process or warrant in the particular case, unless the person executing the same knows that the sentence or process or warrant was in fact passed or issued without authority.