STANFORD — Saying cyberattacks could disrupt critical infrastructure, threaten public safety and undermine the economy, President Barack Obama on Friday called on private corporations to work with the federal government to shore up network defenses.

The Internet is providing new opportunities for innovation and to connect citizens and corporations, but it also opens new vulnerabilities, Obama said in a speech at a cybersecurity conference on the Stanford campus. The only way to defend against those, he said, is for government and corporations to work together.

“This has to be a shared mission,” the president said. “The government cannot do this alone. The fact is that the private sector can’t do this alone either.”

To promote greater cooperation, Obama signed an executive order after his speech that gives government agencies greater leeway to share data — including classified information — with private companies about cyberthreats. The order also encourages the creation of organizations that will serve as hubs of information about particular threats or for companies in specific regions. But the order doesn’t actually require companies to work with each other or the government.

Policymakers have been calling for years for greater cooperation between government and industry but have had little success because both sides have reasons for resisting sharing information, said Bruce Schneier, chief technology officer of Co3 Systems, an Internet security firm in Cambridge, Massachusetts.

Companies, he said, often don’t want to take the public relations hit involved in acknowledging that their networks have been compromised. And the government’s spy agencies are likely reluctant to reveal knowledge about attacks if it might expose their own infiltration of foreign networks, Schneier said.

“Everyone wants to get information. No one wants to give it,” said Schneier, who also is a fellow at Harvard’s Berkman Center for Internet & Society.

Obama’s speech and the White House-sponsored security summit come amid growing concern about the vulnerability of the government and large corporations to cyberattacks. Earlier this month, a hacking attack on health insurance giant Anthem exposed the personal data of up to 80 million customers and employees. That breach follows similar large-scale attacks over the past two years at companies such as Sony, Target, Home Depot and J.P. Morgan Chase.

But it also comes amid widespread skepticism and even anger among technology companies and regular citizens about revelations from Edward Snowden and others that the National Security Agency has infiltrated the networks of major Internet companies and worked to undermine popular security standards. Some reports have also suggested that NSA-led cyber attacks on Iran and North Korea have prompted responses by those countries.

The tension between the government and the tech industry was highlighted by Apple CEO Tim Cook, who spoke just before the president. In his speech, Cook emphasized the importance of protecting consumer privacy and took a veiled shot at critics in the administration and law enforcement who have complained that Apple’s encryption practices have made it difficult for them to pursue criminals and other bad actors. Cook argued that his company and others have an obligation to protect customer data.

“People have entrusted us with their most personal and precious information,” Cook said. “We owe them nothing less than the best protection that we can possibly provide.”

Following the Snowden leaks, U.S. companies have faced challenges overseas from governments and companies concerned about the U.S. government accessing their data, noted Nuala O’Connor, CEO of the Center for Democracy and Technology, an online rights advocacy group.

The president’s move to promote information sharing is a good step in the battle against cyberthreats, she said. But given the revelations about government surveillance, there needs be more discussion about the privacy implications of this cooperation.

“There’s good reason for companies to share data about threats and vulnerabilities,” O’Connor said. But, she added, “we are still very leery of information sharing with government when it involves personal information of citizens and customers.”

In his speech, Obama acknowledged some of the tensions. Although he called for greater privacy protections for citizens, he also argued that the government is responsible for protecting citizens from terrorist and other attacks.

“I have to tell you that grappling with how the government protects the American people from adverse events while at the same time making sure the government itself isn’t abusing its capabilities is hard,” he said.

The president has called on Congress to pass a reform measure that would curtail some of the government’s surveillance capabilities. But civil liberties advocates have argued that the measure doesn’t go nearly far enough. And the president has declined to put in place reforms by using his own executive authority.

In addition to Cook, other prominent business figures speaking at the conference included Box CEO Aaron Levie, PayPal CEO Dan Schulman and PG&E CEO Anthony Earley Jr. The CEOs of Facebook, Google and Yahoo did not take part in the conference, a fact that some observers took as a rebuke to the president.

At the beginning of his speech, the president attempted to lighten the proceedings.

“I was thinking about wearing some black-rimmed glasses, some tape in the middle, but I guess that’s not what you do anymore,” he said, adding that he was promised that if he visited Stanford students would “talk nerdy to me.”

“I’ve got to admit, like, I kind of want to go here,” he said to laughter and applause. “I was trying to figure out why it is that a really nice place like this is wasted on young people — who don’t fully appreciate what you got.”

After hosting two private meetings, one with Cook and other tech leaders and one with students, the president left Stanford for San Francisco, where he was scheduled to speak at a Democratic National Committee fundraiser at the home of venture capitalist Sandy Robinson, in San Francisco’s Russian Hill neighborhood.

Mercury News staff writer Josh Richman contributed to this report. Contact Troy Wolverton at 408-840-4285. Follow him at Twitter.com/troywolv.