Apple’s Andreas Gal flies a lot, but now, he travels in fear, he says.

The artificial intelligence technologist, a former chief technology officer at web-browser firm Mozilla who came to Apple last year, filed a civil-rights complaint Tuesday against federal authorities over his alleged treatment by U.S. Customs and Border Protection at San Francisco International Airport late last year.

“I’ve worked for Silicon Valley companies for more than a decade and international travel is a necessary part of my job,” wrote Gal, an advocate for online privacy and encryption, in a Medium post published Tuesday. “One thing I’ve never experienced while traveling in airports is fear. That changed last December when I returned from a business trip to Europe.”

In filing his complaint with the Department of Homeland Security against Border Protection, Gal is being represented by the American Civil Liberties Union. “As an engineer and executive at Mozilla, Dr. Gal was closely involved in a number of initiatives to prevent warrantless mass surveillance and spread the use of encryption,” the ACLU said in the complaint, which gives Nov. 29 as the date of the incident, rather than December. “He has an active presence on Twitter, where he has expressed his support for online privacy and his strong opposition to the current administration’s policies.”

Gal was asked not only detailed questions about his work at Mozilla by border agents upon his return from a business trip to Sweden, but also about Apple, and border agents indicated an awareness of Gal’s public stance on online privacy, the complaint said.

Border Protection and the Department of Homeland Security did not immediately respond to requests for comment about Gal’s allegations.

In his Medium post, Gal wrote that he was signed up to the Global Entry program, which allows bypassing of queues for people who pass what Border Protection calls “a rigorous background check and in-person interview.”

When he returned to SFO, he said, the Global Entry kiosk directed him to a border agent, who he said kept his passport and sent him to secondary inspection.

“There I quickly found myself surrounded by three armed agents wearing bullet proof vests,” he wrote. “They started to question me aggressively regarding my trip, my current employment, and my past work for Mozilla.”

Agents searched his belongings and demanded he unlock his phone and laptop, he wrote.

“This was rather concerning for me,” Gal wrote. “My phone and laptop are property of my employer and contain unreleased software and proprietary information. I’ve signed a non-disclosure agreement promising not to give anyone access.”

He asked the agents if he could talk with his employer or a lawyer before unlocking his devices, he said. They told him he had no right to speak to an attorney at the border despite his U.S. citizenship, and that failure to comply immediately was a violation of federal law, he said.

“I wasn’t sure what the legal definition of an unreasonable search and seizure was, but three armed men detaining me, threatening me, and refusing to allow me to consult with an attorney definitely felt like one,” he said.

Gal refused to answer further questions and continued to ask to speak to a lawyer, he said.

“Despite initial threats that they would keep my devices if I didn’t unlock them, I was eventually permitted to leave the customs area with my devices. The customs agents did however keep my Global Entry card as a punishment for not complying with their demands,” Gal wrote.

Federal authorities have pushed technology companies to minimize encryption in devices and communications so law enforcement can gain access during investigations. The fight’s highest-profile battle took place between Apple and the FBI, over the agency’s attempt to access a phone used by the perpetrator of a 2015 mass shooting in San Bernardino. Apple refused to help, and the agency ultimately got into the phone using the services of a third-party company. Apple then announced it was closing the vulnerability that allowed that company to gain access.

In Gal’s complaint, the ACLU argued that the attempted search of his iPhone XS and MacBook Pro violated his Fourth Amendment rights against unreasonable search and seizure. Border Protection policies and agents’ questioning of Gal and attempt to search his devices violated his First Amendment right to freedom of speech, the ACLU further contended.

“It appears that (Border Protection) singled out Dr. Gal for questioning and search based on Dr. Gal’s political viewpoints,” the complaint said, adding a claim that the agency retaliated against Gal by revoking his Global Entry pass.

Gal, in his Medium post, said that if the government was trying to scare him, it worked. “I’ve reduced my international travel and my heart pounds every time I go through U.S. customs.”