EU is not a foreign entity, it's made up of the governments of the members(some elected some appointed by the locally elected). So when you leave EU, you end up to live with the entity that tried to introduce it in first place.
If they didn't wanted that, they could have blocked it. However, leaving EU might actually help the government to have a better localised excuse. For example, maybe child abuse is not a big thing in your country but immigration is a hot topic? Then you can have "break the encryption to stop the human smugglers" campaign.