It's definitely not in Australia - and I'd be surprised if that defence worked anywhere else, either.
The law here says that you must assist the police to access data if ordered by a magistrate. The magistrate must be satisfied that you can provide that assistance, but he doesn't ask you before issuing the order - he makes the decision based on what the police tell him. Once that order is issued you commit an offence if you don't comply with it. Your reasons for not complying are irrelevant. (I'm not a laywer, etc...)
The law here says that you must assist the police to access data if ordered by a magistrate. The magistrate must be satisfied that you can provide that assistance, but he doesn't ask you before issuing the order - he makes the decision based on what the police tell him. Once that order is issued you commit an offence if you don't comply with it. Your reasons for not complying are irrelevant. (I'm not a laywer, etc...)