CertificateEmbeddingOption 열거형

정의

서명에 사용되는 X.509 인증서가 저장되는 위치를 지정합니다.

public enum class CertificateEmbeddingOption
public enum CertificateEmbeddingOption
type CertificateEmbeddingOption = 
Public Enum CertificateEmbeddingOption
상속
CertificateEmbeddingOption

필드

InCertificatePart 0

인증서가 자체 PackagePart에 포함되어 있습니다.

InSignaturePart 1

인증서가 추가되는 서명에 대해 만들어지는 SignaturePart에 포함되어 있습니다.

NotEmbedded 2

인증서가 패키지에 포함되지 않았습니다.

예제

다음 예제에서는 속성을 설정 하기 위해 사용 CertificateEmbeddingOption 하는 방법을 보여 있습니다 PackageDigitalSignatureManager.CertificateOption .

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()

설명

인증서가 NotEmbedded 패키지에 있는 경우 서명을 확인하는 애플리케이션은 서명된 서명을 확인하기 위해 인증서의 복사본을 제공해야 합니다.

InSignaturePart 는 두 가지 정보 요소를 <KeyName> <KeyValue>추가하고 저장된 디지털 서명 필드의 KeyInfo 일부로 추가합니다. 합니다 <KeyName><KeyValue> 요소 서명 유효성 검사의 일부로 처리 되지 않으며 따라서 안전 하지 않은 수정 되지 않도록에서 합니다. 애플리케이션에 이러한 두 요소의 유효성에 대 한 모든 가정을 해야 합니다. 검색되지 않은 수정 및 혼동을 방지하려면 애플리케이션에서 InSignaturePart이 옵션을 대신 사용해야 InCertificatePart 합니다. 이 InCertificatePart 옵션은 제공하거나 <KeyValue>노출 <KeyName> 하지 않습니다.

적용 대상

추가 정보