XpsDocument.SignDigitally メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した X.509 証明書を使用して、パッケージ パーツのコレクションに署名します。
オーバーロード
| Name | 説明 |
|---|---|
| SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions) |
指定した X.509 証明書を使用してパッケージ パーツのコレクションに署名します。 |
| SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid) |
指定した X.509 証明書を使用して、パッケージ パーツのコレクションに署名します。 |
| SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid, Boolean) |
指定した X.509 証明書を使用してパッケージ パーツのコレクションに署名します。 |
例
次の例は、 SignDigitally メソッドの使用方法を示しています。
// ------------------------------ 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
SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions)
指定した X.509 証明書を使用してパッケージ パーツのコレクションに署名します。
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
各パートの署名に使用する X.509 証明書。または null して、インストールされている証明書を選択するようにユーザーに求めるメッセージを表示します。
- embedCertificate
- Boolean
true 証明書をパッケージに格納する場合。それ以外の場合は false。
- restrictions
- XpsDigSigPartAlteringRestrictions
署名から除外する必要がある依存パーツを示すフラグ。
戻り値
署名に関する情報を含む XpsDigitalSignature 。
例
次の例は、 SignDigitally メソッドの使用方法を示しています。
// ------------------------------ 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
注釈
certificateがnullされている場合は、インストールされている X.509 証明書 (スマート カード リーダーなど) を選択できるダイアログ ボックスが表示されます。
適用対象
SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid)
指定した X.509 証明書を使用して、パッケージ パーツのコレクションに署名します。
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
各パートの署名に使用する X.509 証明書。または null して、インストールされている証明書を選択するようにユーザーに求めるメッセージを表示します。
- embedCertificate
- Boolean
true 証明書をパッケージに格納する場合。それ以外の場合は false。
- restrictions
- XpsDigSigPartAlteringRestrictions
署名から除外される依存パーツを示すフラグ。
- id
- Guid
署名に割り当てる ID。
戻り値
署名に関する情報を含む XpsDigitalSignature 。
例
次の例は、 SignDigitally メソッドの使用方法を示しています。
// ------------------------------ 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
注釈
certificateがnullされている場合は、インストールされている X.509 証明書 (スマート カード リーダーなど) を選択できるダイアログ ボックスが表示されます。
適用対象
SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid, Boolean)
指定した X.509 証明書を使用してパッケージ パーツのコレクションに署名します。
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
各パートの署名に使用する X.509 証明書。または null して、インストールされている証明書を選択するようにユーザーに求めるメッセージを表示します。
- embedCertificate
- Boolean
true 証明書をパッケージに格納する場合。それ以外の場合は false。
- restrictions
- XpsDigSigPartAlteringRestrictions
署名から除外する依存パーツを示すフラグ。
- id
- Guid
署名に割り当てる ID。
- testIsSignable
- Boolean
true 署名する前に IsSignable が true されていることを確認する場合は。それ以外の場合は false。
戻り値
署名に関する情報を含む XpsDigitalSignature 。
例
次の例は、 SignDigitally メソッドの使用方法を示しています。
// ------------------------------ 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
注釈
certificateがnullされている場合は、インストールされている X.509 証明書 (スマート カード リーダーなど) を選択できるダイアログ ボックスが表示されます。
CryptographicException は、 certificate が null され、証明書がインストールされていない場合にスローされます。