Which is why I never joined the military.
But his statement was a lie by omission. You are not required to obey illegal orders. In fact, you must not.