保护 Office 解决方案Secure Office solutions

Office 解决方案的安全模型涉及多种技术: Visual Studio Tools for Office RuntimeVisual Studio Tools for Office runtimeClickOnceClickOnce,Microsoft Office 和 Internet Explorer 受限的站点区域中的信任中心。The security model for Office solutions involves several technologies: the Visual Studio Tools for Office RuntimeVisual Studio Tools for Office runtime, ClickOnceClickOnce, the Trust Center in Microsoft Office, and the Internet Explorer restricted sites zone. 以下各节介绍不同安全功能的工作方式:The following sections describe how the different security features work:

向 Office 解决方案授予信任Grant trust to Office solutions

向 Office 解决方案授予信任信任意味着修改每个最终用户的安全策略,以便基于以下证据信任 Office 解决方案:Granting trust to Office solutions means modifying the security policy of each end user to trust the Office solution based on the following evidence:

向文档授予信任Grant trust to documents

文档级自定义项要求文档位于被指定为可信位置的目录中。A document-level customization requires that the document be in a directory that is designated as a trusted location. 有关详细信息,请参阅向文档授予信任For more information, see Grant trust to documents.

使用 Windows Installer 时授予信任Grant trust when using Windows Installer

可使用 Windows Installer 创建 MSI 文件以将 Office 解决方案安装到 Program Files 目录,此操作需要管理员权限。You can use Windows Installer to create an MSI file to install Office solutions into the Program Files directory, which requires administrator rights. 对于 Program Files 目录中的 Office 解决方案,Visual Studio 2010 Tools for Office 运行时考虑这些 Office 解决方案视为受信任和不显示 ClickOnce 信任提示。For Office solutions in the Program Files directory, the Visual Studio 2010 Tools for Office runtime considers these Office solutions to be trusted and does not show the ClickOnce trust prompt.

有关 Office 解决方案的特定安全注意事项Specific security considerations for Office solutions

.NET Framework 4.NET Framework 4.NET Framework 4.5.NET Framework 4.5 和 Microsoft Office 提供的安全功能有助保护 Office 解决方案免受各种可能的安全威胁。The security features provided by the .NET Framework 4.NET Framework 4, the .NET Framework 4.5.NET Framework 4.5, and Microsoft Office can help to protect against a variety of possible security threats in Office solutions. 有关详细信息,请参阅Office 解决方案的特定安全注意事项For more information, see Specific security considerations for Office solutions.

开发过程中的安全性Security during development

为了简化开发过程,Visual Studio 设置了每次生成项目时在计算机上运行和调试解决方案所需的安全策略。To make your development process easier, Visual Studio sets the security policy that is required to run and debug your solution on your computer every time that you build a project. 在某些方案中,可能需要采取其他安全措施来开发项目。In some scenarios, you might need to take additional security steps to develop the project.

文档级解决方案Document-level solutions

如果要开发以下类型的项目,则必须将文档的完全限定的路径添加到 Microsoft Office 应用程序中的可信位置列表:The fully qualified path of a document must be added to the list of trusted locations in the Microsoft Office application if you are developing the following types of projects:

  • 文档级解决方案,如位于网络文件共享 \\servername\sharenameDocument-level solutions that are on a network file share such as \\servername\sharename.

  • 使用 word 的文档级解决方案 .doc.docm文件。Document-level solutions for Word that use .doc or .docm files.

    在向可信位置列表中添加文档位置时,请包括子目录,或者专门包括调试和生成文件夹。Include the subdirectories when you add the document location to the trusted locations list, or specifically include the debug and build folders. 有关详细信息,请参阅 Microsoft Office Online 帮助文章创建、 删除或更改你的文件的受信任位置For more information, see the Microsoft Office Online Help article Create, remove, or change a trusted location for your files.

临时证书Temporary certificates

如果不存在签名证书,则 Visual Studio 会创建一个临时证书。Visual Studio creates a temporary certificate if a signing certificate does not already exist. 只应在开发过程中使用此临时证书,在部署时应该购买正式证书。You should use this temporary certificate only during development, and purchase an official certificate for deployment.

该临时证书是在首次生成 Office 项目之后生成的。The temporary certificate is generated after an Office project is first built. 下次按F5,因为该项目标记为已更改时添加证书后,重新生成项目。The next time you press F5, the project is rebuilt because the project is marked as changed when the certificate is added.

在经过一段时间后,可能会有很多临时证书,因此应不定期地清除临时证书。There can be many temporary certificates after a while, so you should clear the temporary certificates occasionally.

Visual Studio Tools for Office 运行时Visual Studio Tools for Office runtime

Visual Studio Tools for Office RuntimeVisual Studio Tools for Office runtime具有功能来验证身份的发布服务器和自定义项授予的权限。The Visual Studio Tools for Office RuntimeVisual Studio Tools for Office runtime has features to verify the identity of the publisher and the permissions that are granted to a customization. 它通过一系列安全检查来验证这些权限。It verifies these permissions through a sequence of security checks.

自定义加载过程中的安全性Security during customization loading

加载的文档级自定义项时,Visual Studio Tools for Office RuntimeVisual Studio Tools for Office runtime始终检查文档是否受信任的位置列表中。When a document-level customization is loaded, the Visual Studio Tools for Office RuntimeVisual Studio Tools for Office runtime always checks whether the document is in the trusted locations list. 此外,运行时检查解决方案是否在应用程序清单中请求 FullTrust。In addition, the runtime checks whether the solution requests FullTrust in the application manifest. 在加载自定义项的过程中,它不再执行其他安全检查。It performs no additional security checks while the customization is loading.

在安装过程中的安全检查的序列Sequence of security checks during installation

安装或更新 Office 解决方案时,Visual Studio Tools for Office RuntimeVisual Studio Tools for Office runtime会按特定顺序执行一组安全检查,以便做出信任决定。When an Office solution is installed or updated, the Visual Studio Tools for Office RuntimeVisual Studio Tools for Office runtime performs a set of security checks in a specific sequence to make a trust decision. 仅当运行时确定解决方案受信任时,才会安装或更新解决方案。A solution is installed or updated only if the runtime determines that the solution is trusted.

你可以开始安装过程中四种方法之一: 通过运行安装程序,通过打开部署清单,通过打开 Microsoft Office 应用程序主机,或通过运行VSTOInstaller.exeYou can start the installation process in one of four ways: by running the Setup program, by opening the deployment manifest, by opening the Microsoft Office application host, or by running VSTOInstaller.exe.

第一项安全检查仅适用于文档级解决方案。The first security check applies only to document-level solutions. 文档级解决方案的文档必须位于可信位置。The document of a document-level solution must be in a trusted location. 如果该文档位于远程网络文件共享上,或者具有 .doc.docm文件扩展名,必须将该文档的位置添加到受信任的位置列表。If the document is on a remote network file share or has a .doc or .docm file name extension, the document's location must be added to the trusted locations list. 有关详细信息,请参阅向文档授予信任For more information, see Grant trust to documents.

VSTO 安全-从 Microsoft Office 安装VSTO security - installing from Microsoft Office

接下来的一组安全检查来自于 Visual Studio Tools for Office RuntimeVisual Studio Tools for Office runtime 和 ClickOnce。The next set of security checks are from the Visual Studio Tools for Office RuntimeVisual Studio Tools for Office runtime and ClickOnce. 若要通过这些检查,Office 解决方案必须请求 FullTrust 权限、 使用不受信任的发布服务器列表中未列出的证书进行签名并在不是在 Internet Explorer 受限区域中的位置。To pass these checks, Office solutions must request FullTrust permissions, be signed with a certificate that is not listed in the Untrusted Publisher list, and be in a location that is not in the Internet Explorer restricted zone. 如果证书是受信任的发布服务器列表中,然后立即安装解决方案。If the certificate is in the Trusted Publisher list, then the solution is installed immediately. 否则,如果解决方案通过所有这些检查,则会继续进行最后一组检查。Otherwise, if it did not fail one of the checks, the solution continues to the final set of checks.

安装解决方案时的 VSTO 安全性VSTO security for installing solutions

如果ClickOnceClickOnce允许信任提示并且解决方案还未被授予信任,运行时将允许最终用户做出信任决定。If the ClickOnceClickOnce trust prompt is allowed and the solution has not yet been granted trust, the runtime will allow the trust decision to be made by the end user. 如果用户向解决方案授予信任,则会向用户包含列表中添加一项。If the user grants trust to the solution, an entry is added to the user inclusion list. 用户包含列表中的所有解决方案都具有完全信任,可以安装和运行。All solutions in the user inclusion list have full trust and can be installed and run.

从 Visual Studio 2010 开始,如果使用 Windows Installer (MSI) 将 Office 解决方案安装到 Program Files 目录,则会跳过包含列表。Starting in Visual Studio 2010, the inclusion list is bypassed if the Office solution is installed by using Windows Installer (MSI) into the Program Files directory. 有关详细信息,请参阅使用包含列表信任 Office 解决方案For more information, see Trust Office solutions by using inclusion lists.

VSTO 安全-使用安装程序安装VSTO security - using the Setup program to install

请参阅See also