XpsDigSigPartAlteringRestrictions 枚举
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定从数字签名的范围内排除的 XPS Package 的各个部件。
此枚举支持其成员值的按位组合。
public enum class XpsDigSigPartAlteringRestrictions
C#
[System.Flags]
public enum XpsDigSigPartAlteringRestrictions
[<System.Flags>]
type XpsDigSigPartAlteringRestrictions =
Public Enum XpsDigSigPartAlteringRestrictions
- 继承
- 属性
名称 | 值 | 说明 |
---|---|---|
Annotations | 2 | 排除批注部件。 |
CoreMetadata | 1 | 排除核心属性部件。 |
None | 0 | 不排除任何部件。 |
SignatureOrigin | 4 | 排除签名源部件。 |
以下示例演示如何使用此枚举对 XPS 文档进行数字签名。
C#
// ------------------------------ SignXps -----------------------------
/// <summary>
/// Signs an XPS document with a given X509 certificate, and if one
/// exists, associates the signature with a given SignatureDefintion
/// spotId GUID.</summary>
/// <param name="xpsDocument">
/// The XPS document to sign.</param>
/// <param name="cert">
/// The X509 certificate to use for signing.</param>
/// <param name="spotId">
/// The nullable spotId GUID of the signature definition.</param>
public void SignXps(
XpsDocument xpsDocument, X509Certificate cert, Guid? spotId )
{
// If there's a SignatureDefinition spotId,
// associate it with the signature.
if (spotId != null)
{
xpsDocument.SignDigitally(
cert, true, XpsDigSigPartAlteringRestrictions.None,
spotId.Value);
}
else
{
xpsDocument.SignDigitally(
cert, true, XpsDigSigPartAlteringRestrictions.None);
}
}// end:SignXps()
' ------------------------------ SignXps -----------------------------
''' <summary>
''' Signs an XPS document with a given X509 certificate, and if one
''' exists, associates the signature with a given SignatureDefintion
''' spotId GUID.</summary>
''' <param name="xpsDocument">
''' The XPS document to sign.</param>
''' <param name="cert">
''' The X509 certificate to use for signing.</param>
''' <param name="spotId">
''' The nullable spotId GUID of the signature definition.</param>
Public Sub SignXps(xpsDocument As XpsDocument, cert As X509Certificate, spotId? As Guid)
' If there's a SignatureDefinition spotId,
' associate it with the signature.
If spotId IsNot Nothing Then
xpsDocument.SignDigitally(cert, True, XpsDigSigPartAlteringRestrictions.None, spotId.Value)
Else
xpsDocument.SignDigitally(cert, True, XpsDigSigPartAlteringRestrictions.None)
End If
End Sub
此枚举具有一个 FlagsAttribute,允许按位组合其成员值。
可以修改指定为从数字签名中排除的部分,而不会使签名失效。 例如,如果文档由多人签名,则需要在首次签名文档时从签名中排除 SignatureOrigin 部件。 (在调用 SignDigitally.) 的 参数中restrictions
指定排除项如果未排除 SignatureOrigin 部件,则任何其他签名都会使第一个签名者的签名失效。
有关数字签名的详细信息,请参阅 开放打包约定的数字签名框架。
有关核心属性和签名源部分的详细信息,请参阅开放 打包约定 规范的第 3 章,可从 下载 https://www.ecma-international.org/publications-and-standards/standards/ecma-376/。
产品 | 版本 |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |