PackageDigitalSignatureManager.Sign 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 X.509 인증서를 사용하여 패키지 파트의 목록을 서명합니다.
오버로드
Sign(IEnumerable<Uri>) |
사용자에게 지정된 패키지 파트 목록을 디지털로 서명하는 데 사용되는 X.509 인증서에 대해 묻는 메시지를 표시합니다. |
Sign(IEnumerable<Uri>, X509Certificate) |
지정된 X.509 인증서를 사용하여 패키지 파트 목록에 서명합니다. |
Sign(IEnumerable<Uri>, X509Certificate, IEnumerable<PackageRelationshipSelector>) |
지정된 X.509 인증서를 사용하여 패키지 파트 및 패키지 관계 목록에 서명합니다. |
Sign(IEnumerable<Uri>, X509Certificate, IEnumerable<PackageRelationshipSelector>, String) |
지정된 X.509 인증서 및 식별자(ID)를 사용하여 패키지 파트 및 패키지 관계 목록에 서명합니다. |
Sign(IEnumerable<Uri>, X509Certificate, IEnumerable<PackageRelationshipSelector>, String, IEnumerable<DataObject>, IEnumerable<Reference>) |
지정된 X.509 인증서 및 서명 식별자(ID)를 사용하여 패키지 파트, 패키지 관계 또는 사용자 지정 개체 목록에 서명합니다. |
예제
다음 예제에서는 내의 파트 목록을 디지털 서명 하는 단계는 Package합니다.
private static void SignAllParts(Package package)
{
if (package == null)
throw new ArgumentNullException("SignAllParts(package)");
// Create the DigitalSignature Manager
PackageDigitalSignatureManager dsm =
new PackageDigitalSignatureManager(package);
dsm.CertificateOption =
CertificateEmbeddingOption.InSignaturePart;
// Create a list of all the part URIs in the package to sign
// (GetParts() also includes PackageRelationship parts).
System.Collections.Generic.List<Uri> toSign =
new System.Collections.Generic.List<Uri>();
foreach (PackagePart packagePart in package.GetParts())
{
// Add all package parts to the list for signing.
toSign.Add(packagePart.Uri);
}
// Add the URI for SignatureOrigin PackageRelationship part.
// The SignatureOrigin relationship is created when Sign() is called.
// Signing the SignatureOrigin relationship disables counter-signatures.
toSign.Add(PackUriHelper.GetRelationshipPartUri(dsm.SignatureOrigin));
// Also sign the SignatureOrigin part.
toSign.Add(dsm.SignatureOrigin);
// Add the package relationship to the signature origin to be signed.
toSign.Add(PackUriHelper.GetRelationshipPartUri(new Uri("/", UriKind.RelativeOrAbsolute)));
// Sign() will prompt the user to select a Certificate to sign with.
try
{
dsm.Sign(toSign);
}
// If there are no certificates or the SmartCard manager is
// not running, catch the exception and show an error message.
catch (CryptographicException ex)
{
MessageBox.Show(
"Cannot Sign\n" + ex.Message,
"No Digital Certificates Available",
MessageBoxButton.OK,
MessageBoxImage.Exclamation);
}
}// end:SignAllParts()
Private Shared Sub SignAllParts(ByVal package As Package)
If package Is Nothing Then
Throw New ArgumentNullException("SignAllParts(package)")
End If
' Create the DigitalSignature Manager
Dim dsm As New PackageDigitalSignatureManager(package)
dsm.CertificateOption = CertificateEmbeddingOption.InSignaturePart
' Create a list of all the part URIs in the package to sign
' (GetParts() also includes PackageRelationship parts).
Dim toSign As New System.Collections.Generic.List(Of Uri)()
For Each packagePart As PackagePart In package.GetParts()
' Add all package parts to the list for signing.
toSign.Add(packagePart.Uri)
Next
' Add the URI for SignatureOrigin PackageRelationship part.
' The SignatureOrigin relationship is created when Sign() is called.
' Signing the SignatureOrigin relationship disables counter-signatures.
toSign.Add(PackUriHelper.GetRelationshipPartUri(dsm.SignatureOrigin))
' Also sign the SignatureOrigin part.
toSign.Add(dsm.SignatureOrigin)
' Add the package relationship to the signature origin to be signed.
toSign.Add(PackUriHelper.GetRelationshipPartUri(New Uri("/", UriKind.RelativeOrAbsolute)))
' Sign() will prompt the user to select a Certificate to sign with.
Try
dsm.Sign(toSign)
Catch ex As CryptographicException
' If there are no certificates or the SmartCard manager is
' not running, catch the exception and show an error message.
MessageBox.Show("Cannot Sign" & vbLf & ex.Message, "No Digital Certificates Available", MessageBoxButton.OK, MessageBoxImage.Exclamation)
End Try
End Sub
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
target = value
Return value
End Function
' end:SignAllParts()
Sign(IEnumerable<Uri>)
사용자에게 지정된 패키지 파트 목록을 디지털로 서명하는 데 사용되는 X.509 인증서에 대해 묻는 메시지를 표시합니다.
public:
System::IO::Packaging::PackageDigitalSignature ^ Sign(System::Collections::Generic::IEnumerable<Uri ^> ^ parts);
public System.IO.Packaging.PackageDigitalSignature Sign (System.Collections.Generic.IEnumerable<Uri> parts);
member this.Sign : seq<Uri> -> System.IO.Packaging.PackageDigitalSignature
Public Function Sign (parts As IEnumerable(Of Uri)) As PackageDigitalSignature
매개 변수
- parts
- IEnumerable<Uri>
서명할 PackagePart 요소의 URI(Uniform Resource Identifier) 목록입니다.
반환
parts
목록에 서명하는 데 사용되는 디지털 서명입니다.
예제
다음 예제에서는 패키지 파트 목록을 디지털 서명 하는 방법을 보여 줍니다.
private static void SignAllParts(Package package)
{
if (package == null)
throw new ArgumentNullException("SignAllParts(package)");
// Create the DigitalSignature Manager
PackageDigitalSignatureManager dsm =
new PackageDigitalSignatureManager(package);
dsm.CertificateOption =
CertificateEmbeddingOption.InSignaturePart;
// Create a list of all the part URIs in the package to sign
// (GetParts() also includes PackageRelationship parts).
System.Collections.Generic.List<Uri> toSign =
new System.Collections.Generic.List<Uri>();
foreach (PackagePart packagePart in package.GetParts())
{
// Add all package parts to the list for signing.
toSign.Add(packagePart.Uri);
}
// Add the URI for SignatureOrigin PackageRelationship part.
// The SignatureOrigin relationship is created when Sign() is called.
// Signing the SignatureOrigin relationship disables counter-signatures.
toSign.Add(PackUriHelper.GetRelationshipPartUri(dsm.SignatureOrigin));
// Also sign the SignatureOrigin part.
toSign.Add(dsm.SignatureOrigin);
// Add the package relationship to the signature origin to be signed.
toSign.Add(PackUriHelper.GetRelationshipPartUri(new Uri("/", UriKind.RelativeOrAbsolute)));
// Sign() will prompt the user to select a Certificate to sign with.
try
{
dsm.Sign(toSign);
}
// If there are no certificates or the SmartCard manager is
// not running, catch the exception and show an error message.
catch (CryptographicException ex)
{
MessageBox.Show(
"Cannot Sign\n" + ex.Message,
"No Digital Certificates Available",
MessageBoxButton.OK,
MessageBoxImage.Exclamation);
}
}// end:SignAllParts()
Private Shared Sub SignAllParts(ByVal package As Package)
If package Is Nothing Then
Throw New ArgumentNullException("SignAllParts(package)")
End If
' Create the DigitalSignature Manager
Dim dsm As New PackageDigitalSignatureManager(package)
dsm.CertificateOption = CertificateEmbeddingOption.InSignaturePart
' Create a list of all the part URIs in the package to sign
' (GetParts() also includes PackageRelationship parts).
Dim toSign As New System.Collections.Generic.List(Of Uri)()
For Each packagePart As PackagePart In package.GetParts()
' Add all package parts to the list for signing.
toSign.Add(packagePart.Uri)
Next
' Add the URI for SignatureOrigin PackageRelationship part.
' The SignatureOrigin relationship is created when Sign() is called.
' Signing the SignatureOrigin relationship disables counter-signatures.
toSign.Add(PackUriHelper.GetRelationshipPartUri(dsm.SignatureOrigin))
' Also sign the SignatureOrigin part.
toSign.Add(dsm.SignatureOrigin)
' Add the package relationship to the signature origin to be signed.
toSign.Add(PackUriHelper.GetRelationshipPartUri(New Uri("/", UriKind.RelativeOrAbsolute)))
' Sign() will prompt the user to select a Certificate to sign with.
Try
dsm.Sign(toSign)
Catch ex As CryptographicException
' If there are no certificates or the SmartCard manager is
' not running, catch the exception and show an error message.
MessageBox.Show("Cannot Sign" & vbLf & ex.Message, "No Digital Certificates Available", MessageBoxButton.OK, MessageBoxImage.Exclamation)
End Try
End Sub
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
target = value
Return value
End Function
' end:SignAllParts()
설명
인증서 선택 대화 상자 모달을 특정 창에 설정 된 ParentWindow 호출 하기 전에 속성 Sign합니다.
Sign 없는 경우 기본 인증서 저장소에서 인증서에 대 한 메시지가 나타나지 않습니다.
적용 대상
Sign(IEnumerable<Uri>, X509Certificate)
지정된 X.509 인증서를 사용하여 패키지 파트 목록에 서명합니다.
public:
System::IO::Packaging::PackageDigitalSignature ^ Sign(System::Collections::Generic::IEnumerable<Uri ^> ^ parts, System::Security::Cryptography::X509Certificates::X509Certificate ^ certificate);
public System.IO.Packaging.PackageDigitalSignature Sign (System.Collections.Generic.IEnumerable<Uri> parts, System.Security.Cryptography.X509Certificates.X509Certificate certificate);
member this.Sign : seq<Uri> * System.Security.Cryptography.X509Certificates.X509Certificate -> System.IO.Packaging.PackageDigitalSignature
Public Function Sign (parts As IEnumerable(Of Uri), certificate As X509Certificate) As PackageDigitalSignature
매개 변수
- parts
- IEnumerable<Uri>
서명할 PackagePart 요소의 URI(Uniform Resource Identifier) 목록입니다.
- certificate
- X509Certificate
지정된 각 parts
에 디지털 서명하는 데 사용할 X.509 인증서입니다.
반환
지정된 parts
목록에 서명하는 데 사용할 디지털 서명 또는 인증서가 없거나 사용자가 인증서 선택 대화 상자에서 "취소"를 클릭한 경우 null
입니다.
예제
다음 예제에서는 내의 파트 목록을 디지털 서명 하는 방법을 보여 줍니다는 Package합니다.
private static void SignAllParts(Package package)
{
if (package == null)
throw new ArgumentNullException("SignAllParts(package)");
// Create the DigitalSignature Manager
PackageDigitalSignatureManager dsm =
new PackageDigitalSignatureManager(package);
dsm.CertificateOption =
CertificateEmbeddingOption.InSignaturePart;
// Create a list of all the part URIs in the package to sign
// (GetParts() also includes PackageRelationship parts).
System.Collections.Generic.List<Uri> toSign =
new System.Collections.Generic.List<Uri>();
foreach (PackagePart packagePart in package.GetParts())
{
// Add all package parts to the list for signing.
toSign.Add(packagePart.Uri);
}
// Add the URI for SignatureOrigin PackageRelationship part.
// The SignatureOrigin relationship is created when Sign() is called.
// Signing the SignatureOrigin relationship disables counter-signatures.
toSign.Add(PackUriHelper.GetRelationshipPartUri(dsm.SignatureOrigin));
// Also sign the SignatureOrigin part.
toSign.Add(dsm.SignatureOrigin);
// Add the package relationship to the signature origin to be signed.
toSign.Add(PackUriHelper.GetRelationshipPartUri(new Uri("/", UriKind.RelativeOrAbsolute)));
// Sign() will prompt the user to select a Certificate to sign with.
try
{
dsm.Sign(toSign);
}
// If there are no certificates or the SmartCard manager is
// not running, catch the exception and show an error message.
catch (CryptographicException ex)
{
MessageBox.Show(
"Cannot Sign\n" + ex.Message,
"No Digital Certificates Available",
MessageBoxButton.OK,
MessageBoxImage.Exclamation);
}
}// end:SignAllParts()
Private Shared Sub SignAllParts(ByVal package As Package)
If package Is Nothing Then
Throw New ArgumentNullException("SignAllParts(package)")
End If
' Create the DigitalSignature Manager
Dim dsm As New PackageDigitalSignatureManager(package)
dsm.CertificateOption = CertificateEmbeddingOption.InSignaturePart
' Create a list of all the part URIs in the package to sign
' (GetParts() also includes PackageRelationship parts).
Dim toSign As New System.Collections.Generic.List(Of Uri)()
For Each packagePart As PackagePart In package.GetParts()
' Add all package parts to the list for signing.
toSign.Add(packagePart.Uri)
Next
' Add the URI for SignatureOrigin PackageRelationship part.
' The SignatureOrigin relationship is created when Sign() is called.
' Signing the SignatureOrigin relationship disables counter-signatures.
toSign.Add(PackUriHelper.GetRelationshipPartUri(dsm.SignatureOrigin))
' Also sign the SignatureOrigin part.
toSign.Add(dsm.SignatureOrigin)
' Add the package relationship to the signature origin to be signed.
toSign.Add(PackUriHelper.GetRelationshipPartUri(New Uri("/", UriKind.RelativeOrAbsolute)))
' Sign() will prompt the user to select a Certificate to sign with.
Try
dsm.Sign(toSign)
Catch ex As CryptographicException
' If there are no certificates or the SmartCard manager is
' not running, catch the exception and show an error message.
MessageBox.Show("Cannot Sign" & vbLf & ex.Message, "No Digital Certificates Available", MessageBoxButton.OK, MessageBoxImage.Exclamation)
End Try
End Sub
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
target = value
Return value
End Function
' end:SignAllParts()
적용 대상
Sign(IEnumerable<Uri>, X509Certificate, IEnumerable<PackageRelationshipSelector>)
지정된 X.509 인증서를 사용하여 패키지 파트 및 패키지 관계 목록에 서명합니다.
public:
System::IO::Packaging::PackageDigitalSignature ^ Sign(System::Collections::Generic::IEnumerable<Uri ^> ^ parts, System::Security::Cryptography::X509Certificates::X509Certificate ^ certificate, System::Collections::Generic::IEnumerable<System::IO::Packaging::PackageRelationshipSelector ^> ^ relationshipSelectors);
public System.IO.Packaging.PackageDigitalSignature Sign (System.Collections.Generic.IEnumerable<Uri> parts, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Collections.Generic.IEnumerable<System.IO.Packaging.PackageRelationshipSelector> relationshipSelectors);
member this.Sign : seq<Uri> * System.Security.Cryptography.X509Certificates.X509Certificate * seq<System.IO.Packaging.PackageRelationshipSelector> -> System.IO.Packaging.PackageDigitalSignature
Public Function Sign (parts As IEnumerable(Of Uri), certificate As X509Certificate, relationshipSelectors As IEnumerable(Of PackageRelationshipSelector)) As PackageDigitalSignature
매개 변수
- parts
- IEnumerable<Uri>
서명할 PackagePart 개체의 URI(Uniform Resource Identifier) 목록입니다.
- certificate
- X509Certificate
지정된 각 파트 및 관계에 디지털 서명하는 데 사용할 X.509 인증서입니다.
- relationshipSelectors
- IEnumerable<PackageRelationshipSelector>
서명할 PackageRelationship 개체 목록입니다.
반환
parts
및 relationshipSelectors
목록에 지정된 요소에 서명하는 데 사용되는 디지털 시그니처입니다.
예외
parts
또는 relationshipSelectors
모두 서명할 개체를 지정하지 않습니다.
예제
다음 예제에서는 패키지 파트 목록을 디지털 서명 하는 방법을 보여 줍니다.
private static void SignAllParts(Package package)
{
if (package == null)
throw new ArgumentNullException("SignAllParts(package)");
// Create the DigitalSignature Manager
PackageDigitalSignatureManager dsm =
new PackageDigitalSignatureManager(package);
dsm.CertificateOption =
CertificateEmbeddingOption.InSignaturePart;
// Create a list of all the part URIs in the package to sign
// (GetParts() also includes PackageRelationship parts).
System.Collections.Generic.List<Uri> toSign =
new System.Collections.Generic.List<Uri>();
foreach (PackagePart packagePart in package.GetParts())
{
// Add all package parts to the list for signing.
toSign.Add(packagePart.Uri);
}
// Add the URI for SignatureOrigin PackageRelationship part.
// The SignatureOrigin relationship is created when Sign() is called.
// Signing the SignatureOrigin relationship disables counter-signatures.
toSign.Add(PackUriHelper.GetRelationshipPartUri(dsm.SignatureOrigin));
// Also sign the SignatureOrigin part.
toSign.Add(dsm.SignatureOrigin);
// Add the package relationship to the signature origin to be signed.
toSign.Add(PackUriHelper.GetRelationshipPartUri(new Uri("/", UriKind.RelativeOrAbsolute)));
// Sign() will prompt the user to select a Certificate to sign with.
try
{
dsm.Sign(toSign);
}
// If there are no certificates or the SmartCard manager is
// not running, catch the exception and show an error message.
catch (CryptographicException ex)
{
MessageBox.Show(
"Cannot Sign\n" + ex.Message,
"No Digital Certificates Available",
MessageBoxButton.OK,
MessageBoxImage.Exclamation);
}
}// end:SignAllParts()
Private Shared Sub SignAllParts(ByVal package As Package)
If package Is Nothing Then
Throw New ArgumentNullException("SignAllParts(package)")
End If
' Create the DigitalSignature Manager
Dim dsm As New PackageDigitalSignatureManager(package)
dsm.CertificateOption = CertificateEmbeddingOption.InSignaturePart
' Create a list of all the part URIs in the package to sign
' (GetParts() also includes PackageRelationship parts).
Dim toSign As New System.Collections.Generic.List(Of Uri)()
For Each packagePart As PackagePart In package.GetParts()
' Add all package parts to the list for signing.
toSign.Add(packagePart.Uri)
Next
' Add the URI for SignatureOrigin PackageRelationship part.
' The SignatureOrigin relationship is created when Sign() is called.
' Signing the SignatureOrigin relationship disables counter-signatures.
toSign.Add(PackUriHelper.GetRelationshipPartUri(dsm.SignatureOrigin))
' Also sign the SignatureOrigin part.
toSign.Add(dsm.SignatureOrigin)
' Add the package relationship to the signature origin to be signed.
toSign.Add(PackUriHelper.GetRelationshipPartUri(New Uri("/", UriKind.RelativeOrAbsolute)))
' Sign() will prompt the user to select a Certificate to sign with.
Try
dsm.Sign(toSign)
Catch ex As CryptographicException
' If there are no certificates or the SmartCard manager is
' not running, catch the exception and show an error message.
MessageBox.Show("Cannot Sign" & vbLf & ex.Message, "No Digital Certificates Available", MessageBoxButton.OK, MessageBoxImage.Exclamation)
End Try
End Sub
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
target = value
Return value
End Function
' end:SignAllParts()
설명
간의 parts
고 relationshipSelectors
로그인에 하나 이상의 요소가 있어야 합니다.
적용 대상
Sign(IEnumerable<Uri>, X509Certificate, IEnumerable<PackageRelationshipSelector>, String)
지정된 X.509 인증서 및 식별자(ID)를 사용하여 패키지 파트 및 패키지 관계 목록에 서명합니다.
public:
System::IO::Packaging::PackageDigitalSignature ^ Sign(System::Collections::Generic::IEnumerable<Uri ^> ^ parts, System::Security::Cryptography::X509Certificates::X509Certificate ^ certificate, System::Collections::Generic::IEnumerable<System::IO::Packaging::PackageRelationshipSelector ^> ^ relationshipSelectors, System::String ^ signatureId);
public System.IO.Packaging.PackageDigitalSignature Sign (System.Collections.Generic.IEnumerable<Uri> parts, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Collections.Generic.IEnumerable<System.IO.Packaging.PackageRelationshipSelector> relationshipSelectors, string signatureId);
member this.Sign : seq<Uri> * System.Security.Cryptography.X509Certificates.X509Certificate * seq<System.IO.Packaging.PackageRelationshipSelector> * string -> System.IO.Packaging.PackageDigitalSignature
Public Function Sign (parts As IEnumerable(Of Uri), certificate As X509Certificate, relationshipSelectors As IEnumerable(Of PackageRelationshipSelector), signatureId As String) As PackageDigitalSignature
매개 변수
- parts
- IEnumerable<Uri>
서명할 PackagePart 개체의 URI(Uniform Resource Identifier) 목록입니다.
- certificate
- X509Certificate
지정된 각 파트 및 관계에 디지털 서명하는 데 사용할 X.509 인증서입니다.
- relationshipSelectors
- IEnumerable<PackageRelationshipSelector>
서명할 PackageRelationship 개체 목록입니다.
- signatureId
- String
서명과 연결할 식별 문자열입니다.
반환
parts
및 relationshipSelectors
목록에 지정된 요소에 서명하는 데 사용되는 디지털 시그니처입니다.
예외
parts
또는 relationshipSelectors
모두 서명할 요소를 지정하지 않습니다.
예제
다음 예제에서는 패키지 파트 목록을 디지털 서명 하는 방법을 보여 줍니다.
private static void SignAllParts(Package package)
{
if (package == null)
throw new ArgumentNullException("SignAllParts(package)");
// Create the DigitalSignature Manager
PackageDigitalSignatureManager dsm =
new PackageDigitalSignatureManager(package);
dsm.CertificateOption =
CertificateEmbeddingOption.InSignaturePart;
// Create a list of all the part URIs in the package to sign
// (GetParts() also includes PackageRelationship parts).
System.Collections.Generic.List<Uri> toSign =
new System.Collections.Generic.List<Uri>();
foreach (PackagePart packagePart in package.GetParts())
{
// Add all package parts to the list for signing.
toSign.Add(packagePart.Uri);
}
// Add the URI for SignatureOrigin PackageRelationship part.
// The SignatureOrigin relationship is created when Sign() is called.
// Signing the SignatureOrigin relationship disables counter-signatures.
toSign.Add(PackUriHelper.GetRelationshipPartUri(dsm.SignatureOrigin));
// Also sign the SignatureOrigin part.
toSign.Add(dsm.SignatureOrigin);
// Add the package relationship to the signature origin to be signed.
toSign.Add(PackUriHelper.GetRelationshipPartUri(new Uri("/", UriKind.RelativeOrAbsolute)));
// Sign() will prompt the user to select a Certificate to sign with.
try
{
dsm.Sign(toSign);
}
// If there are no certificates or the SmartCard manager is
// not running, catch the exception and show an error message.
catch (CryptographicException ex)
{
MessageBox.Show(
"Cannot Sign\n" + ex.Message,
"No Digital Certificates Available",
MessageBoxButton.OK,
MessageBoxImage.Exclamation);
}
}// end:SignAllParts()
Private Shared Sub SignAllParts(ByVal package As Package)
If package Is Nothing Then
Throw New ArgumentNullException("SignAllParts(package)")
End If
' Create the DigitalSignature Manager
Dim dsm As New PackageDigitalSignatureManager(package)
dsm.CertificateOption = CertificateEmbeddingOption.InSignaturePart
' Create a list of all the part URIs in the package to sign
' (GetParts() also includes PackageRelationship parts).
Dim toSign As New System.Collections.Generic.List(Of Uri)()
For Each packagePart As PackagePart In package.GetParts()
' Add all package parts to the list for signing.
toSign.Add(packagePart.Uri)
Next
' Add the URI for SignatureOrigin PackageRelationship part.
' The SignatureOrigin relationship is created when Sign() is called.
' Signing the SignatureOrigin relationship disables counter-signatures.
toSign.Add(PackUriHelper.GetRelationshipPartUri(dsm.SignatureOrigin))
' Also sign the SignatureOrigin part.
toSign.Add(dsm.SignatureOrigin)
' Add the package relationship to the signature origin to be signed.
toSign.Add(PackUriHelper.GetRelationshipPartUri(New Uri("/", UriKind.RelativeOrAbsolute)))
' Sign() will prompt the user to select a Certificate to sign with.
Try
dsm.Sign(toSign)
Catch ex As CryptographicException
' If there are no certificates or the SmartCard manager is
' not running, catch the exception and show an error message.
MessageBox.Show("Cannot Sign" & vbLf & ex.Message, "No Digital Certificates Available", MessageBoxButton.OK, MessageBoxImage.Exclamation)
End Try
End Sub
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
target = value
Return value
End Function
' end:SignAllParts()
설명
합니다 parts
목록은 비어 있을 수 또는 null
경우 relationshipSelectors
하나 이상의 항목이 포함 되어 있습니다.
합니다 relationshipSelectors
목록은 비어 있을 수 또는 null
경우 parts
하나 이상의 항목이 포함 되어 있습니다.
간의 합니다 parts
목록 및 relationshipSelectors
로그인에 하나 이상의 요소가 있어야 합니다.
적용 대상
Sign(IEnumerable<Uri>, X509Certificate, IEnumerable<PackageRelationshipSelector>, String, IEnumerable<DataObject>, IEnumerable<Reference>)
지정된 X.509 인증서 및 서명 식별자(ID)를 사용하여 패키지 파트, 패키지 관계 또는 사용자 지정 개체 목록에 서명합니다.
public:
System::IO::Packaging::PackageDigitalSignature ^ Sign(System::Collections::Generic::IEnumerable<Uri ^> ^ parts, System::Security::Cryptography::X509Certificates::X509Certificate ^ certificate, System::Collections::Generic::IEnumerable<System::IO::Packaging::PackageRelationshipSelector ^> ^ relationshipSelectors, System::String ^ signatureId, System::Collections::Generic::IEnumerable<System::Security::Cryptography::Xml::DataObject ^> ^ signatureObjects, System::Collections::Generic::IEnumerable<System::Security::Cryptography::Xml::Reference ^> ^ objectReferences);
[System.Security.SecurityCritical]
public System.IO.Packaging.PackageDigitalSignature Sign (System.Collections.Generic.IEnumerable<Uri> parts, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Collections.Generic.IEnumerable<System.IO.Packaging.PackageRelationshipSelector> relationshipSelectors, string signatureId, System.Collections.Generic.IEnumerable<System.Security.Cryptography.Xml.DataObject> signatureObjects, System.Collections.Generic.IEnumerable<System.Security.Cryptography.Xml.Reference> objectReferences);
public System.IO.Packaging.PackageDigitalSignature Sign (System.Collections.Generic.IEnumerable<Uri> parts, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Collections.Generic.IEnumerable<System.IO.Packaging.PackageRelationshipSelector> relationshipSelectors, string signatureId, System.Collections.Generic.IEnumerable<System.Security.Cryptography.Xml.DataObject> signatureObjects, System.Collections.Generic.IEnumerable<System.Security.Cryptography.Xml.Reference> objectReferences);
[<System.Security.SecurityCritical>]
member this.Sign : seq<Uri> * System.Security.Cryptography.X509Certificates.X509Certificate * seq<System.IO.Packaging.PackageRelationshipSelector> * string * seq<System.Security.Cryptography.Xml.DataObject> * seq<System.Security.Cryptography.Xml.Reference> -> System.IO.Packaging.PackageDigitalSignature
member this.Sign : seq<Uri> * System.Security.Cryptography.X509Certificates.X509Certificate * seq<System.IO.Packaging.PackageRelationshipSelector> * string * seq<System.Security.Cryptography.Xml.DataObject> * seq<System.Security.Cryptography.Xml.Reference> -> System.IO.Packaging.PackageDigitalSignature
Public Function Sign (parts As IEnumerable(Of Uri), certificate As X509Certificate, relationshipSelectors As IEnumerable(Of PackageRelationshipSelector), signatureId As String, signatureObjects As IEnumerable(Of DataObject), objectReferences As IEnumerable(Of Reference)) As PackageDigitalSignature
매개 변수
- parts
- IEnumerable<Uri>
서명할 PackagePart 개체의 URI(Uniform Resource Identifier) 목록입니다.
- certificate
- X509Certificate
지정된 각 파트 및 관계에 디지털 서명하는 데 사용할 X.509 인증서입니다.
- relationshipSelectors
- IEnumerable<PackageRelationshipSelector>
서명할 PackageRelationship 개체 목록입니다.
- signatureId
- String
서명과 연결할 식별 문자열입니다.
- signatureObjects
- IEnumerable<DataObject>
서명할 사용자 지정 데이터 개체의 목록입니다.
- objectReferences
- IEnumerable<Reference>
서명할 사용자 지정 개체에 대한 참조 목록입니다.
반환
parts
및 relationshipSelectors
목록에 지정된 요소에 서명하는 데 사용되는 디지털 시그니처입니다.
- 특성
예외
parts
, relationshipSelectors
, signatureObjects
또는 objectReferences
모두 서명할 요소를 지정하지 않습니다.
서명 중인 파트의 ContentType이 비어 있거나, null
이거나 또는 정의되지 않은 TransformMapping을 참조합니다.
signatureId
가 이 아니 null
고 유효한 XML 스키마 ID가 아닙니다(예: 선행 숫자로 시작).
설명
로그인에 하나 이상의 요소가 있어야 parts
, relationshipSelectors
를 signatureObjects
, 또는 objectReferences
합니다.
참고
용어 Object
, Manifest
, Reference
합니다 SignatureProperties
, 및 Transform
내용은 다음의 두 주의 요소 형식 및 W3C XML 서명 구문 및 처리 사양에 정의 된 태그를 참조 하십시오 https://www.w3.org/TR/xmldsig-core/.
이 및 다른 Sign 메서드 오버 로드는 현재 사용 TransformMapping 정의 하는 사전을 Transform
패키지 부분을 기반으로 적용할 ContentType합니다. Microsoft OPC Open Packaging Conventions () 사양 현재 허용 합니다. 두 개의 유효한 Transform
알고리즘: C14 및 C14N 합니다. W3C XML 서명 구문 및 처리 표준 빈 없도록 Manifest
태그입니다. 또한 Open Packaging Conventions 사양에는 Package-특정 Object
둘 다 포함 하는 태그 Manifest
및 SignatureProperties
태그입니다. 각 Manifest
또한 태그 하나 이상 포함할 수도 Reference
태그입니다. 이러한 태그는 각 서명에 서명 하나 이상 필요 PackagePart (비어 있지 않은 부분 태그) 또는 PackageRelationship (비어 있지 않은 relationshipSelectors
)를 서명 하기 위한 용도로 필요한 경우에 signatureObjects
또는 objectReferences
합니다.
이 Sign 메서드를 무시 합니다 DigestMethod 상호 연결 된 속성 Reference 에 정의 된 objectReferences
합니다.
이 Sign 오버로드는 사용자 지정 Object
태그가 필요한 XML 서명 생성을 지원합니다. 제공된 Object
태그를 서명하려면 로컬 조각 구문에서 태그를 지정하는 URI(Uniform Resource Identifier)와 함께 해당 Reference
태그를 Object
제공해야 합니다. 예를 들어 경우는 Object
태그의 ID URI에서 "myObject"는는 Reference
태그 "#myObject" 됩니다. 에 대 한 서명 되지 않은 개체를 더 Reference
필요 합니다.
적용 대상
.NET