Joseph Gordon-Levitt got to know National Security Agency whistle-blower Edward Snowden over the course of making Oliver Stone’s “Snowden,” a dramatization of not just the leak of classified documents that made the former NSA contractor a wanted man but also of the evolution of a conservative young man who had hoped to serve in the Special Forces at the height of the Iraq War.

Close to each other in age, the 35-year-old actor and Snowden, 33, are friendly now. In the run-up to the release of “Snowden,” directed by Oliver Stone, Gordon-Levitt has even released a short video, “Edward Snowden: It’s Only Getting Better,” a partnership between his HitRecord collaborative production company and the ACLU, in which Snowden talks about the impact of technology on democracy.

But in 2013, when Snowden was in a Hong Kong hotel room revealing all to filmmaker Laura Poitras (who would use the interviews to make the Oscar-winning film “Citizenfour”) and journalists Glenn Greenwald and Ewen Mac-Askill, Gordon-Levitt was not paying too much attention to the news. He missed the international furor that ensued when Snowden released classified documents supporting his contention that the NSA engaged in mass domestic spying on American citizens.

“The truth is, when this story broke, I was hardly aware of it,” Gordon-Levitt says. “I remember hearing his name. When Oliver Stone offered me this job, which was roughly a little less than a year after it had happened, first I was excited to be getting a job offer from Oliver Stone.”

Gordon-Levitt dived into research for the role, but there could be none more valuable than what could be gleaned from Snowden himself. And so the actor found himself in Moscow, meeting with Snowden and his girlfriend, Lindsay Mills (portrayed in the movie by Shailene Woodley).

Meeting him “frankly made me nervous, and I don’t really get nervous,” says Gordon-Levitt. “What was funny is he’s always trying to take the attention off of himself personally and put the attention on the issues that he raises. But I’m an actor. I was going to play him in a movie, so I was focused on him personally, just his little human details, how he talks, how he sits, how he shakes your hand, how he eats his lunch.”

That Snowden at one time wanted to be a soldier and wanted to fight in Iraq — a training injury ended that dream — was a key to the character for Gordon-Levitt.

“To be honest, I’ve never risked my life for anything, and I hope I never have to,” Gordon-Levitt says. “There’s a different sort of fascinating person that is that brave. That’s something that Oliver Stone has told a lot of stories about, people like that, obviously. You find a lot of it in military stories.

“This is no coincidence that I think Oliver was attracted to this character just like he’s attracted to the characters in ‘Platoon’ or he was attracted to the character in ‘Born on the Fourth of July.’”

There is no profit to be had for Gordon-Levitt from “Snowden.” He donated his paycheck to the ACLU. Part of the money funded the “It’s Only Getting Better” video. The rest of the money is earmarked for the work the organization does on free speech, privacy and technology, areas entwined with Snowden’s disclosures. Making the video proved to be another eye-opener for Gordon-Levitt, who was not expecting Snowden’s optimism.

“When you think of Edward Snowden, you think he’s someone who shined a light on this very dark thing that was happening with technology,” Gordon-Levitt says. “You’d think that he was a pessimist. It was great to hear him say, ‘Yes, I think there are potential downsides, but ultimately I embrace technology. Moving into the future, the positives will outweigh the negatives.’ I find that inspiring.”

Pam Grady is a San Francisco freelance writer. Twitter: @cinepam

Snowden (R) opens Friday, Sept. 16, at Bay Area theaters.

To see a trailer: https://snowdenfilm.com

To watch “Edward Snowden: It’s Only Getting Better”: youtube.com/watch?v=ysCQfx-UEpA