FBI director nominee James Comey told the Senate Judiciary Committee that whistleblowers are ‘a critical element’ of a democracy. (The Washington Post)

James B. Comey, President Obama’s nominee to be director of the FBI, defended the National Security Agency’s surveillance programs Tuesday as a critical tool for counterterrorism but said he would be open to more transparency with the secret court that oversees the government’s collection operations.

“I’m not familiar with the details of the current programs,” Comey said during a 21 / 2-hour confirmation hearing before the Senate Judiciary Committee. “Obviously, I haven’t been cleared for anything like that. . . . I do know that as a general matter that the collection of metadata and analysis of metadata is a valuable tool in counterterrorism.”

The government’s ability to gather and store metadata, which records the dates, times and locations of phone calls, has become controversial in light of disclosures by former NSA contractor Edward Snowden about sweeping ­top-secret programs.

“When is enough enough?” asked Judiciary Committee Chairman Patrick J. Leahy (D-Vt.). “Just because we have the ability to collect huge amounts of data doesn’t mean that we should be doing it. “

Comey answered a wide range of questions about civilian drones, the Boston Marathon bombing and a host of legal issues. Those included his role in writing legal opinions that sanctioned interrogation techniques, used during the George W. Bush administration, that have been condemned as torture.

James Comey, Obama’s nominee for FBI director, said Tuesday that he fought under President George W. Bush to end waterboarding. (The Washington Post)

Sen. Charles E. Schumer (D-N.Y.) asked Comey whether he would support releasing declassified summaries of opinions issued by the Foreign Intelligence Surveillance Court so that the public can better understand the workings of the court that oversees domestic surveillance programs. Comey said he thought that was largely a question for the director of national intelligence but that he wanted to be a voice for greater transparency.

“Transparency is a key value, especially when it helps the American people understand what the government is doing to try to keep them safe,” Comey said.

Comey also said that he did not believe that the judges on the secret court are “rubber stamps” for the government — an opinion that is shared by James Robertson, a former federal district judge who served on the court and spoke at a separate hearing Tuesday.

But Robertson said the Foreign Intelligence Surveillance Act court system is flawed because it does not allow legal adversaries to question the government’s actions.

“Anyone who has been a judge will tell you a judge needs to hear both sides of a case,” Robertson said during a hearing of the federal oversight board directed by Obama to scrutinize government surveillance.

The nomination of Comey, who was the deputy attorney general in the Bush administration, has elicited strong bipartisan support, and his confirmation is all but assured.

But Comey has come under fire from civil-liberties advocates for his role in signing off on some Bush-era “enhanced interrogation” techniques, such as waterboarding. And Leahy pressed Comey on the issue. “Do you agree that waterboarding is torture and is illegal?” Leahy asked.

“Yes,” Comey replied. “When I first learned about waterboarding . . . my reaction as a citizen and as a leader was, ‘This is torture.’ It’s still what I think. If I were FBI director, we would never have anything to do with that.”

Comey said that he tried to stop the use of such harsh methods but that the law was “very vague.”

“I thought it was irresponsible both as a policy matter and as a legal matter,” Comey said, “and so I objected to it and took that directly to the attorney general and made my case that was wrong. He disagreed with me and overruled me.”

Sen. Dianne Feinstein (D-Calif.) asked Comey for his view on the force-feeding of detainees at the U.S. facility at Guantanamo Bay, Cuba. Comey declined to take a position, saying it would not fall under his purview as FBI director.

If confirmed, Comey will replace Robert S. Mueller III, who is retiring after 12 years and who led the FBI through the attacks of Sept 11, 2001, and the transformation of the bureau in the years afterward.

In his opening statement, Comey said that when he was first approached about the job this year, his wife, Patrice, urged him to say yes for two reasons: “She said: ‘This is who you are. You’ve always been happiest when you’re in government service. This is what you love. And second, they’re not going to pick you, anyway.’ ” But on June 21, Obama nominated Comey to head the bureau, saying he has “law enforcement in his blood.” The president praised his independence, integrity and dedication.

With his wife and five children seated behind him, Comey acknowledged how tough the job of FBI director can be.

“I’m sure that things will go wrong,” Comey said. “What I pledge to you, though, is to follow Bob Mueller’s example of staring hard at those mistakes, learning from those mistakes and getting better as a result of those mistakes.”