It is perfectly legal. People say it is entrapment. Entrapment is when a cop forces you to do something you would not normally do.
__________________
Governments are instituted among Men, deriving their just powers from the consent of the governed, — That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it