Here's a thing I remember being taught early in my military national service. Something I think applies to most forces globally?
Obeying an illegal order is an offence. "The orders were illegal" is a valid defence when facing court martial for refusing to obey orders, so long as those orders actually were illegal.