SAN FRANCISCO — A federal appeals court on Wednesday struggled with the legality of the secrecy cloak the FBI has thrown over its use of national security letters to gather information from Internet providers and telecommunications companies.

During nearly an hour of arguments, a three-judge 9th U.S. Circuit Court of Appeals panel sent no clear signal on whether it would strike down a provision in the Patriot Act that allows the FBI to send the letters in anti-terrorism and domestic spying probes and bars recipients from disclosing them.

Civil liberties groups sued to invalidate the national security letters, arguing the gag orders violate the free speech rights of the telecom companies that received them in 2011.

The appeals court appeared troubled that the federal government has not taken steps to rid the law of its First Amendment problems, particularly in light of a 2008 New York federal appeals court ruling that gave guidance in a similar legal challenge.

Judge N. Randy Smith expressed some concern about the obstacles to contesting the letters, suggesting the U.S. Justice Department and Congress need to address them.

“The government can keep these things going on permanently,” Smith told Justice Department lawyer Douglas Letter.

But Judge Sandra Ikuta wondered if the restrictions might be allowed in view of national security considerations, citing the fact there is some disclosure about the national security letters in twice-a-year reports from tech companies and others.

“It seems to be more of a confidentiality statute,” she said to Kurt Opsahl, a lawyer for the Electronic Frontier Foundation.

The appeals court is reviewing U.S. District Judge Susan Illston’s ruling last year finding that the letters, known as NSLs, violate the First Amendment because they forbid the recipients from saying anything about them, including publicly disclosing the fact they have received one.

The telecom that has challenged the legality of the letters cannot identify itself in the case because of the threat of federal prison, nor can its lawyers from the Electronic Frontier Foundation, the civil liberties group fighting the legal battle.

The government has asked the appeals court to overturn Illston’s ruling, which would bar the FBI from using the letters unless the Obama administration persuades Congress to modify the Patriot Act to address the free-speech concerns.

The letters are considered a linchpin of the federal domestic surveillance program, even more so than the National Security Agency’s Internet data collection, which is aimed primarily at overseas targets.

Between 2003 and 2011, the number of such letters issued by the FBI ranged between 16,511 and 56,507 a year, according to Justice Department figures.

Government lawyers defend the constitutionality of the letters and insist the gag provisions protect investigations.

During Wednesday’s hearing, Letter warned that losing the investigative tool would “greatly hamstring” the FBI’s efforts to protect national security.

A host of organizations have lined up against the government, ranging from media groups to Silicon Valley companies such as Google and Facebook.

Twitter added fuel to the controversy this week, suing the federal government over the restrictions on publicly disclosing the scope of information sought from users in the course of national security-related investigations.

Twitter argues the Justice Department is violating the company’s First Amendment rights by barring it from releasing more specific reports on government snooping in Twitter user accounts.

Lawyers for the telecom company at the center of the 9th Circuit case also point to a series of federal Inspector General reports between 2007 and 2010 that found abuses in the FBI’s reliance on the national security letters and suggested Congress might need to create further checks on them, such as more court oversight.

Howard Mintz covers legal affairs. Contact him at 408-286-0236 or follow him at Twitter.com/hmintz