It is legal to challenge a police officer, but only until he or she asks you to stop.

5-3-6 Use of Fighting Words.

No person shall insult, taunt, or challenge another in a manner likely to provoke a disorderly response. If the person to whom such insult, taunt, or challenge is directed is a police officer, there is no violation of this section until the police officer requests the person to cease and discontinue the conduct, but the person repeats or continues the conduct.