Apple Inc., the world’s largest info-tech company, now stands in defiance of a federal court order, saying it will fight attempts to force it to help the FBI crack the iPhone of a San Bernardino terrorist involved in a major attack on U.S. soil that left 14 dead and 22 injured. Apple says the government is overreaching and would be setting a dangerous precedent.

The company is wrong on both counts, but the world of encrypted information is a complex one. It is worthwhile to proceed carefully, because this could prove to be a critical showdown in the growing clash between privacy and national security.

First, it should be noted that the government negotiated for two months with Apple executives. When those talks fell apart, Justice Department officials turned to a federal judge, who ordered the company to create a way to bypass the security feature on the phone. The FBI had obtained a warrant to search the phone and, not incidentally, the consent of the employer that had issued the phone to Syed Rizwah Farook.

Apple has complied with what Justice officials characterize as “a significant number” of government requests in the past, including unlocking individual phones. Apple CEO Tim Cook has become increasingly concerned about customer privacy, particularly after 2013 revelations by whistleblower Edward Snowden about massive government surveillance operations. The company has continued to tighten its security systems and decided to no longer maintain a way into individual phones. Farook’s iPhone 5c was among those with a 10-tries-and-wipe feature that essentially turns it into a brick if too many false passwords are entered. Newer operating systems employ ever-more-sophisticated security features.

The government’s authority to get private information, such as texts, photos and other stored data, through a warrant is not at issue. The key here is whether the government can compel a private company to create a means of access that the company contends will weaken its premier product.

Cook maintains that creating a “master key” to disable security on Farook’s phone ultimately would jeopardize every iPhone. With more than 100 million in use across the country, that is no small threat. There are, however, technology experts who say Apple could create a bypass — allowing for what’s called a brute force hack — without affecting other phones.

Could such a bypass then leak out? It’s possible, but all corporate secrets face that danger. Might the government start knocking on Apple’s door repeatedly, wanting to unlock the devices of other would-be terrorists and high-level criminals? Clearly, it already has. To maintain privacy as much as possible, the government should limit its requests to matters of national security. Could hackers devise a bypass of their own? Some tech experts say that it’s possible and that no one should assume their device is completely protected.

Here’s the dilemma: The safer our smartphones are for us, the safer they are for those who would do this nation harm. Are we willing to provide those individuals or groups a secure means of communication on the most sophisticated portable device the world has known and block national security and law enforcement officials from gaining entry?

Fearmongering aside, it is important to remember that we can allow one thing without allowing everything. Forcing government officials to obtain warrants and provide a measure of proof that they have few other options for obtaining needed information are important protections.

Those conditions were met here. Terrorist activities pose an ongoing threat to Americans. This latest attack came at a holiday party by county employees, most of whom knew their attacker simply as a co-worker.

Within a tested legal framework, a company should be compelled to provide assistance on issues that can help prevent such assaults. Apple has a duty to safeguard both its products and its reputation. It does not have the right to jeopardize the nation’s safety.