The American Civil Liberties Union (ACLU) of Northern California filed a complaint Tuesday on behalf of top Apple employee Andreas Gal, who says he was illegally harassed by U.S. Customs and Border Protection (CBP) officials when he asked to speak to a lawyer before they could search his company devices.

Gal, who was previously CTO at Mozilla and the CEO and founder of Silk Labs, an AI startup acquired by Apple, was reportedly asked by Customs officers about his work and his advocacy for online privacy. Then, according to the complaint, officers asked for the passwords to his Apple-issued phone and computer, and he asked to speak to his employer or a lawyer before doing so, since the contents were covered by a nondisclosure agreement.

They declined to let him speak to a lawyer and threatened him with prosecution, according to the complaint.

“Critically, Dr. Gal never refused to provide the passcodes to access the electronic devices in his possession; he only asked that he be allowed to consult with an attorney to ensure that he would not violate nondisclosure agreements with his employer,” according to the complaint. “In the interactions with CBP officers, Dr. Gal repeated many times that he would comply with any legal requirement, but that he needed to consult with an attorney to understand his rights before he could do so.”

Gal, who holds a PhD in computer science, was ultimately released without charge and with the devices, but officers confiscated his Global Entry card and said he’d be removed from the expedited screening program, according to the complaint.

A CBP spokesperson declined to comment, citing privacy concerns.

“CBP’s baseless detention and intrusive interrogation of Andreas Gal and the attempted search of his devices violated his Fourth Amendment rights,” said William Freeman, ACLU of Northern California senior counsel, in a statement. “Furthermore, CBP’s policies lack protections for First Amendment rights by allowing interrogation and device searches that may be based on a traveler’s political beliefs, activism, nation of origin, or identity.”