This is literally the Nuremberg defense: the crimes committed by the Third Reich were mostly legal under German law at the time they were carried out -- and in many cases refusing to carry out those orders would have been a crime under those laws.
Isn't the Nuremberg defence more as a defence to breaking the law because you had to follow orders?
The Nuremberg judges apparently had an easier job specifically because Nazi Germany was reluctant to codify many offenses as law. "I didn't want to break the law" is apparently a better defense in such circumstances than "just following orders".
The main outcome of Nuremberg was international agreement that certain crimes are so serious that they go beyond any national law. That's not what this case was about.