XpsDocument.SignDigitally XpsDocument.SignDigitally XpsDocument.SignDigitally XpsDocument.SignDigitally Method

정의

지정된 X.509 인증서를 사용하여 패키지 파트의 컬렉션에 서명합니다.Signs a collection of package parts by using a specified X.509 certificate.

오버로드

SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions)

지정된 X.509 인증서를 사용하여 패키지 파트의 컬렉션을 서명합니다.Signs a collection of package parts with a specified X.509 certificate.

SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid)

지정된 X.509 인증서를 사용하여 패키지 파트의 컬렉션에 서명합니다.Signs a collection of package parts by using a specified X.509 certificate.

SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid, Boolean) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid, Boolean) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid, Boolean) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid, Boolean)

지정된 X.509 인증서를 사용하여 패키지 파트의 컬렉션을 서명합니다.Signs a collection of package parts with a specified X.509 certificate.

예제

다음 예제에서는 SignDigitally 메서드를 사용하는 방법을 보여 줍니다.The following example shows how to use the SignDigitally method.


// ------------------------------ 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(ByVal xpsDocument As XpsDocument, ByVal cert As X509Certificate, ByVal 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 ' end:SignXps()

SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions)

지정된 X.509 인증서를 사용하여 패키지 파트의 컬렉션을 서명합니다.Signs a collection of package parts with a specified X.509 certificate.

public:
 System::Windows::Xps::Packaging::XpsDigitalSignature ^ SignDigitally(System::Security::Cryptography::X509Certificates::X509Certificate ^ certificate, bool embedCertificate, System::Windows::Xps::Packaging::XpsDigSigPartAlteringRestrictions restrictions);
public System.Windows.Xps.Packaging.XpsDigitalSignature SignDigitally (System.Security.Cryptography.X509Certificates.X509Certificate certificate, bool embedCertificate, System.Windows.Xps.Packaging.XpsDigSigPartAlteringRestrictions restrictions);
member this.SignDigitally : System.Security.Cryptography.X509Certificates.X509Certificate * bool * System.Windows.Xps.Packaging.XpsDigSigPartAlteringRestrictions -> System.Windows.Xps.Packaging.XpsDigitalSignature
Public Function SignDigitally (certificate As X509Certificate, embedCertificate As Boolean, restrictions As XpsDigSigPartAlteringRestrictions) As XpsDigitalSignature

매개 변수

certificate
X509Certificate X509Certificate X509Certificate X509Certificate

각 파트에 서명하는 데 사용할 X.509 인증서 또는 사용자에게 설치된 인증서를 선택하라는 메시지를 표시하면 null입니다.The X.509 certificate to use in signing each part; or null to prompt the user to select an installed certificate.

embedCertificate
Boolean Boolean Boolean Boolean

패키지에 인증서를 저장하면 true이고, 저장하지 않으면 false입니다.true to store the certificate in the package; otherwise, false.

restrictions
XpsDigSigPartAlteringRestrictions XpsDigSigPartAlteringRestrictions XpsDigSigPartAlteringRestrictions XpsDigSigPartAlteringRestrictions

서명에서 제외해야 하는 종속 파트를 나타내는 플래그입니다.Flags that indicate what dependent parts must be excluded from the signing.

반환

서명에 대한 정보가 들어 있는 XpsDigitalSignature입니다.An XpsDigitalSignature that contains information about the signature.

예제

다음 예제에서는 SignDigitally 메서드를 사용하는 방법을 보여 줍니다.The following example shows how to use the SignDigitally method.


// ------------------------------ 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(ByVal xpsDocument As XpsDocument, ByVal cert As X509Certificate, ByVal 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 ' end:SignXps()

설명

하는 경우 certificatenull와 같은 스마트 카드 판독기가 설치 된 X.509 인증서를 선택할 수 있도록 해 주는 대화 상자가 나타납니다.If certificate is null, a dialog box appears that enables the user to select an installed X.509 certificate, such as from a smart card reader.

SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid)

지정된 X.509 인증서를 사용하여 패키지 파트의 컬렉션에 서명합니다.Signs a collection of package parts by using a specified X.509 certificate.

public:
 System::Windows::Xps::Packaging::XpsDigitalSignature ^ SignDigitally(System::Security::Cryptography::X509Certificates::X509Certificate ^ certificate, bool embedCertificate, System::Windows::Xps::Packaging::XpsDigSigPartAlteringRestrictions restrictions, Guid id);
public System.Windows.Xps.Packaging.XpsDigitalSignature SignDigitally (System.Security.Cryptography.X509Certificates.X509Certificate certificate, bool embedCertificate, System.Windows.Xps.Packaging.XpsDigSigPartAlteringRestrictions restrictions, Guid id);
member this.SignDigitally : System.Security.Cryptography.X509Certificates.X509Certificate * bool * System.Windows.Xps.Packaging.XpsDigSigPartAlteringRestrictions * Guid -> System.Windows.Xps.Packaging.XpsDigitalSignature
Public Function SignDigitally (certificate As X509Certificate, embedCertificate As Boolean, restrictions As XpsDigSigPartAlteringRestrictions, id As Guid) As XpsDigitalSignature

매개 변수

certificate
X509Certificate X509Certificate X509Certificate X509Certificate

각 파트에 서명하는 데 사용할 X.509 인증서 또는 사용자에게 설치된 인증서를 선택하라는 메시지를 표시하면 null입니다.The X.509 certificate to use in signing each part; or null to prompt the user to select an installed certificate.

embedCertificate
Boolean Boolean Boolean Boolean

패키지에 인증서를 저장하면 true이고, 저장하지 않으면 false입니다.true to store the certificate in the package; otherwise, false.

restrictions
XpsDigSigPartAlteringRestrictions XpsDigSigPartAlteringRestrictions XpsDigSigPartAlteringRestrictions XpsDigSigPartAlteringRestrictions

서명에서 제외되는 종속 파트를 나타내는 플래그입니다.Flags that indicate what dependent parts are excluded from the signing.

id
Guid Guid Guid Guid

서명에 할당할 ID입니다.The ID to assign to the signature.

반환

서명에 대한 정보가 들어 있는 XpsDigitalSignature입니다.An XpsDigitalSignature that contains information about the signature.

예제

다음 예제에서는 SignDigitally 메서드를 사용하는 방법을 보여 줍니다.The following example shows how to use the SignDigitally method.


// ------------------------------ 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(ByVal xpsDocument As XpsDocument, ByVal cert As X509Certificate, ByVal 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 ' end:SignXps()

설명

하는 경우 certificatenull와 같은 스마트 카드 판독기가 설치 된 X.509 인증서를 선택할 수 있도록 해 주는 대화 상자가 나타납니다.If certificate is null, a dialog box appears that enables the user to select an installed X.509 certificate, such as from a smart card reader.

SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid, Boolean) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid, Boolean) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid, Boolean) SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid, Boolean)

지정된 X.509 인증서를 사용하여 패키지 파트의 컬렉션을 서명합니다.Signs a collection of package parts with a specified X.509 certificate.

public:
 System::Windows::Xps::Packaging::XpsDigitalSignature ^ SignDigitally(System::Security::Cryptography::X509Certificates::X509Certificate ^ certificate, bool embedCertificate, System::Windows::Xps::Packaging::XpsDigSigPartAlteringRestrictions restrictions, Guid id, bool testIsSignable);
public System.Windows.Xps.Packaging.XpsDigitalSignature SignDigitally (System.Security.Cryptography.X509Certificates.X509Certificate certificate, bool embedCertificate, System.Windows.Xps.Packaging.XpsDigSigPartAlteringRestrictions restrictions, Guid id, bool testIsSignable);
member this.SignDigitally : System.Security.Cryptography.X509Certificates.X509Certificate * bool * System.Windows.Xps.Packaging.XpsDigSigPartAlteringRestrictions * Guid * bool -> System.Windows.Xps.Packaging.XpsDigitalSignature
Public Function SignDigitally (certificate As X509Certificate, embedCertificate As Boolean, restrictions As XpsDigSigPartAlteringRestrictions, id As Guid, testIsSignable As Boolean) As XpsDigitalSignature

매개 변수

certificate
X509Certificate X509Certificate X509Certificate X509Certificate

각 파트에 서명하는 데 사용할 X.509 인증서 또는 사용자에게 설치된 인증서를 선택하라는 메시지를 표시하면 null입니다.The X.509 certificate to use in signing each part; or null to prompt the user to select an installed certificate.

embedCertificate
Boolean Boolean Boolean Boolean

패키지에 인증서를 저장하면 true이고, 저장하지 않으면 false입니다.true to store the certificate in the package; otherwise, false.

restrictions
XpsDigSigPartAlteringRestrictions XpsDigSigPartAlteringRestrictions XpsDigSigPartAlteringRestrictions XpsDigSigPartAlteringRestrictions

서명에서 제외할 종속 파트를 나타내는 플래그입니다.Flags that indicate what dependent parts to exclude from the signing.

id
Guid Guid Guid Guid

서명에 할당할 ID입니다.The ID to assign to the signature.

testIsSignable
Boolean Boolean Boolean Boolean

서명 전에 IsSignabletrue인지 확인하면 true이고, 확인하지 않으면 false입니다.true to verify that IsSignable is true before signing; otherwise, false.

반환

서명에 대한 정보가 들어 있는 XpsDigitalSignature입니다.An XpsDigitalSignature that contains information about the signature.

예제

다음 예제에서는 SignDigitally 메서드를 사용하는 방법을 보여 줍니다.The following example shows how to use the SignDigitally method.


// ------------------------------ 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(ByVal xpsDocument As XpsDocument, ByVal cert As X509Certificate, ByVal 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 ' end:SignXps()

설명

하는 경우 certificatenull와 같은 스마트 카드 판독기가 설치 된 X.509 인증서를 선택할 수 있도록 해 주는 대화 상자가 표시 됩니다.If certificate is null, a dialog box is presented that enables the user to select an installed X.509 certificate, such as from a smart card reader.

CryptographicException 이 throw certificatenull 및 인증서 설치.CryptographicException is thrown if certificate is null and no certificates are installed.

적용 대상