This is simply untrue and there is a well established legal defense known as "entrapment by estoppel" to protect a defendant against an act which has been explicitly sanctioned by a government official.
https://en.wikipedia.org/wiki/Entrapment#Entrapment_by_estop...