Freigeben über


PublisherIdentityPermission-Konstruktor (X509Certificate)

Initialisiert eine neue Instanz der PublisherIdentityPermission-Klasse mit dem angegebenen Authenticode X.509v3-Zertifikat.

Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Sub New ( _
    certificate As X509Certificate _
)
'Usage
Dim certificate As X509Certificate

Dim instance As New PublisherIdentityPermission(certificate)
public PublisherIdentityPermission (
    X509Certificate certificate
)
public:
PublisherIdentityPermission (
    X509Certificate^ certificate
)
public PublisherIdentityPermission (
    X509Certificate certificate
)
public function PublisherIdentityPermission (
    certificate : X509Certificate
)

Parameter

  • certificate
    Ein X.509-Zertifikat, das die Identität des Softwareherausgebers darstellt.

Ausnahmen

Ausnahmetyp Bedingung

ArgumentNullException

Der certificate-Parameter ist NULL (Nothing in Visual Basic).

ArgumentException

Der certificate-Parameter ist kein gültiges Zertifikat.

Hinweise

Das X.509-Zertifikat definiert die Identität des angegebenen Softwareherausgebers, die durch die Codesignatur von Authenticode festgelegt wurde.

Beispiel

Im folgenden Codebeispiel wird die Verwendung des PublisherIdentityPermission-Konstruktors veranschaulicht. Dieses Codebeispiel ist Teil eines unten dargestellten und umfangreicheren Beispiels.

Dim certPath = ("Publisher.cer")

' Create evidence for the Publisher.cer certificate.
Dim publisher As New Publisher( _
    X509Certificate.CreateFromCertFile(certPath))

Dim evidence As New Evidence
evidence.AddHost(publisher)

' Create an identity permission based on publisher evidence.
Dim x509Permission As New PublisherIdentityPermission( _
PermissionState.None)
x509Permission = publisher.CreateIdentityPermission(evidence)

' Verify that callers higher in the stack have been granted 
' permission.
x509Permission.Demand()
string certPath = ("Publisher.cer");

// Create evidence for the Publisher.cer certificate.
Publisher publisher =
    new Publisher(X509Certificate.CreateFromCertFile(certPath));
Evidence evidence = new Evidence();
evidence.AddHost(publisher);

// Create an identity permission based on publisher evidence.
PublisherIdentityPermission x509Permission =
    (PublisherIdentityPermission)publisher.
    CreateIdentityPermission(evidence);

// Verify that callers higher in the stack have been granted 
// permission.
x509Permission.Demand();
String^ certPath = "Publisher.cer";

// Create evidence for the Publisher.cer certificate.
Publisher^ publisher =
    gcnew Publisher(X509Certificate::CreateFromCertFile(certPath));
Evidence^ evidence = gcnew Evidence();
evidence->AddHost(publisher);

// Create an identity permission based on publisher evidence.
PublisherIdentityPermission^ x509Permission =
    (PublisherIdentityPermission^)
    publisher->CreateIdentityPermission(evidence);

// Verify that callers higher in the stack have been granted 
// permission.
x509Permission->Demand();
String certPath = "Publisher.cer";
// Create evidence for the Publisher.cer certificate.
Publisher publisher = new Publisher(X509Certificate.
    CreateFromCertFile(certPath));
Evidence evidence = new Evidence();
evidence.AddHost(publisher);
// Create an identity permission based on publisher evidence.
PublisherIdentityPermission x509Permission 
    = (PublisherIdentityPermission)(
    publisher.CreateIdentityPermission(evidence));
// Verify that callers higher in the stack have been granted 
// permission.
x509Permission.Demand();

Im Folgenden finden Sie ein vollständiges Codebeispiel, in dem die deklarativen und imperativen Formen der PublisherIdentityPermission-Klasse veranschaulicht werden, um die Signierung einer Assembly mit einem bestimmten Zertifikat anzufordern.

Imports System
Imports System.Security
Imports System.Security.Policy
Imports System.Security.Permissions
Imports System.Security.Cryptography.X509Certificates

' Declarative security requesting evidence of the Publisher.cer 
' X509 certificate.
<Assembly: PublisherIdentityPermissionAttribute( _
    SecurityAction.RequestMinimum, _
    CertFile:="Publisher.cer")> 
Public Class Form1
    Inherits System.Windows.Forms.Form

    ' Event handler for Run button.
    Private Sub Button1_Click( _
        ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click

        tbxOutput.Cursor = Cursors.WaitCursor
        tbxOutput.Text = ""

        ' Create a new publisherIdentity passing in the Form for output.
        Dim publisherIdentity As New PublisherIdentity(sender.parent.parent)

        If (publisherIdentity.DemandCertificate()) Then
            tbxOutput.AppendText("PublisherIdentity successfully verified" + _
                " the certificate." + vbCrLf)
        Else
            tbxOutput.AppendText("PublisherIdentity was unable to verify " + _
                "the certificate." + vbCrLf)
        End If

        ' Align interface and conclude application.
        tbxOutput.AppendText(vbCrLf + "This sample completed " + _
            "successfully; press Exit to continue.")

        tbxOutput.Cursor = Cursors.Default
    End Sub
    ' Event handler for Exit button.
    Private Sub Button2_Click( _
        ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button2.Click

        Application.Exit()
    End Sub
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call.

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Panel2 As System.Windows.Forms.Panel
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents tbxOutput As System.Windows.Forms.RichTextBox
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Panel2 = New System.Windows.Forms.Panel
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.Panel1 = New System.Windows.Forms.Panel
        Me.tbxOutput = New System.Windows.Forms.RichTextBox
        Me.Panel2.SuspendLayout()
        Me.Panel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Panel2
        '
        Me.Panel2.Controls.Add(Me.Button1)
        Me.Panel2.Controls.Add(Me.Button2)
        Me.Panel2.Dock = System.Windows.Forms.DockStyle.Bottom
        Me.Panel2.DockPadding.All = 20
        Me.Panel2.Location = New System.Drawing.Point(0, 320)
        Me.Panel2.Name = "Panel2"
        Me.Panel2.Size = New System.Drawing.Size(616, 64)
        Me.Panel2.TabIndex = 1
        '
        'Button1
        '
        Me.Button1.Dock = System.Windows.Forms.DockStyle.Right
        Me.Button1.Font = New System.Drawing.Font( _
            "Microsoft Sans Serif", _
            9.0!, _
            System.Drawing.FontStyle.Regular, _
            System.Drawing.GraphicsUnit.Point, _
            CType(0, Byte))
        Me.Button1.Location = New System.Drawing.Point(446, 20)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(75, 24)
        Me.Button1.TabIndex = 2
        Me.Button1.Text = "&Run"
        '
        'Button2
        '
        Me.Button2.Dock = System.Windows.Forms.DockStyle.Right
        Me.Button2.Font = New System.Drawing.Font( _
            "Microsoft Sans Serif", _
            9.0!, _
            System.Drawing.FontStyle.Regular, _
            System.Drawing.GraphicsUnit.Point, _
            CType(0, Byte))
        Me.Button2.Location = New System.Drawing.Point(521, 20)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(75, 24)
        Me.Button2.TabIndex = 3
        Me.Button2.Text = "E&xit"
        '
        'Panel1
        '
        Me.Panel1.Controls.Add(Me.tbxOutput)
        Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Panel1.DockPadding.All = 20
        Me.Panel1.Location = New System.Drawing.Point(0, 0)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(616, 320)
        Me.Panel1.TabIndex = 2
        '
        'tbxOutput
        '
        Me.tbxOutput.AccessibleDescription = _
            "Displays output from application."
        Me.tbxOutput.AccessibleName = "Output textbox."
        Me.tbxOutput.Dock = System.Windows.Forms.DockStyle.Fill
        Me.tbxOutput.Location = New System.Drawing.Point(20, 20)
        Me.tbxOutput.Name = "tbxOutput"
        Me.tbxOutput.Size = New System.Drawing.Size(576, 280)
        Me.tbxOutput.TabIndex = 1
        Me.tbxOutput.Text = "Click the Run button to run the application."
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
        Me.ClientSize = New System.Drawing.Size(616, 384)
        Me.Controls.Add(Me.Panel1)
        Me.Controls.Add(Me.Panel2)
        Me.Name = "Form1"
        Me.Text = "PublisherIdentity"
        Me.Panel2.ResumeLayout(False)
        Me.Panel1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region
End Class

Class PublisherIdentity

    Private outputControl

    Public Sub New(ByVal form As Form1)
        outputControl = form.tbxOutput
    End Sub
    Public Function DemandCertificate() As Boolean
        Dim blRetVal = False

        Try
            Dim certPath = ("Publisher.cer")

            ' Create evidence for the Publisher.cer certificate.
            Dim publisher As New Publisher( _
                X509Certificate.CreateFromCertFile(certPath))

            Dim evidence As New Evidence
            evidence.AddHost(publisher)

            ' Create an identity permission based on publisher evidence.
            Dim x509Permission As New PublisherIdentityPermission( _
            PermissionState.None)
            x509Permission = publisher.CreateIdentityPermission(evidence)

            ' Verify that callers higher in the stack have been granted 
            ' permission.
            x509Permission.Demand()

            blRetVal = True

        Catch ex As System.IO.FileNotFoundException
            outputControl.AppendText("Unable to load the certificate file.")
            outputControl.AppendText(ex.ToString() + vbCrLf)

        Catch ex As SecurityException
            outputControl.AppendText("An exception was thrown:")
            outputControl.AppendText(ex.ToString() + vbCrLf)
        End Try

        Return blRetVal
    End Function
End Class
'
' This sample produces the following output:
'
' An exception was thrown:System.Security.SecurityException: Request for the
' permission of type System.Security.Permissions.PublisherIdentityPermission, 
' mscorlib, Version=1.0.5000.0, Culture=neutral, 
' PublicKeyToken=b77a5c561934e089 failed.
'  at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet 
' grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
' PermissionToken permToken)
'  at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
' permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
' checkFrames, Int32 unrestrictedOverride)
'  at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap,
' StackCrawlMark& stackMark)
'  at System.Security.CodeAccessPermission.Demand()
'  at WindowsApplication1.PublisherIdentity.DemandCertificate()

' The state of the failed permission was: 
' <IPermission class="System.Security.Permissions.PublisherIdentityPermission,
'  mscorlib, Version=1.0.5000.0, Culture=neutral, 
'  PublicKeyToken=b77a5c561934e089"
'            version="1"
'            X509v3Certificate="3082020E30820177A0030201020210491BB8DBE6EBC991
' 4A5ACF0698CC0E18300D06092A864886F70D0101040500301C311A3018060355040313115075
' 626C69736865724964656E74697479301E170D3034303232343031303233365A170D33393132
' 33313233353935395A301C311A3018060355040313115075626C69736865724964656E746974
' 7930819F300D06092A864886F70D010101050003818D0030818902818100BF589FB7CD2D6DB8
' 9EEF6B394A4012B7727AD71EC1E342234DF15391296B5A5667F90E4B36D0C39AE4418612300F
' 8DC1435E6390468DC055D5759D1C772D9221188B6EC93AE59783F33644B5FA9952D1F079BA4E
' 6AF253E3EA1505E10DFD1ABEEF74D9D216E690C9CF3A3AF01138B7D69AD0E7155D56630A34A0
' 3014FEFBC7750203010001A351304F304D0603551D01044630448010BFB7A1D6CD5289C1A206
' 2A691D4E325EA11E301C311A3018060355040313115075626C69736865724964656E74697479
' 8210491BB8DBE6EBC9914A5ACF0698CC0E18300D06092A864886F70D01010405000381810061
' 476417D94228CAA1003D3A68BF4265DB607A5806BBB48A31AD7726DC73F7BB2504171C5C11BC
' 6903C5D649A05C27640007C7CCF0C32D66E7BB640E353F86CBAC2E74777B3794222F82333933
' A80F9269EB4AB2319EA519F7F78922066F2C7A47F99286C8B898A5145F0C056FB82FBD136347
' 2CD8C38E9225FD5CB7CD4520A8"/>
'
' PublisherIdentity was unable to verify the certificate.
'
' This sample completed successfully; press Exit to continue.
using System;
using System.Security;
using System.Security.Policy;
using System.Security.Permissions;
using System.Security.Cryptography.X509Certificates;

// Declarative security requesting evidence of the Publisher.cer 
// X509 certificate.
[assembly:PublisherIdentityPermissionAttribute(SecurityAction.RequestMinimum,
    CertFile="Publisher.cer")]
class PublisherIdentity
{
    [STAThread]
    static void Main(string[] args)
    {
        if (new PublisherIdentity().DemandCertificate())
        {
            Console.WriteLine("PublisherIdentity successfully verified " + 
                "the certificate.");
        }
        else
        {
            Console.WriteLine("PublisherIdentity was unable to verify the " +
                "certificate.");
        }
    }

    private bool DemandCertificate()
    {
        bool blRetVal = false;
        try 
        {
            string certPath = ("Publisher.cer");

            // Create evidence for the Publisher.cer certificate.
            Publisher publisher =
                new Publisher(X509Certificate.CreateFromCertFile(certPath));
            Evidence evidence = new Evidence();
            evidence.AddHost(publisher);

            // Create an identity permission based on publisher evidence.
            PublisherIdentityPermission x509Permission =
                (PublisherIdentityPermission)publisher.
                CreateIdentityPermission(evidence);

            // Verify that callers higher in the stack have been granted 
            // permission.
            x509Permission.Demand();

            blRetVal = true;
        }
        catch (SecurityException ex)
        {
            Console.WriteLine("An exception was thrown:" + ex.ToString());
        }

        return blRetVal;
    }
}
//
// This sample produces the following output:
//
// An exception was thrown:System.Security.SecurityException: Request for the
// permission of type System.Security.Permissions.PublisherIdentityPermission,
// mscorlib, Version=1.0.5000.0, Culture=neutral, 
// PublicKeyToken=b77a5c561934e089 failed.
//  at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet 
// grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
// PermissionToken permToken)
//  at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
// permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
// checkFrames, Int32 unrestrictedOverride)
//  at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission 
// cap, StackCrawlMark& stackMark)
//  at System.Security.CodeAccessPermission.Demand()
//  at WindowsApplication1.PublisherIdentity.DemandCertificate()

// The state of the failed permission was: 
// <IPermission class="System.Security.Permissions.PublisherIdentityPermission
// ,mscorlib, Version=1.0.5000.0, Culture=neutral, 
//  PublicKeyToken=b77a5c561934e089"
//            version="1"
//            X509v3Certificate="3082020E30820177A0030201020210491BB8DBE6EBC99
// 14A5ACF0698CC0E18300D06092A864886F70D0101040500301C311A30180603550403131150
// 75626C69736865724964656E74697479301E170D3034303232343031303233365A170D33393
// 13233313233353935395A301C311A3018060355040313115075626C69736865724964656E74
// 69747930819F300D06092A864886F70D010101050003818D0030818902818100BF589FB7CD2
// D6DB89EEF6B394A4012B7727AD71EC1E342234DF15391296B5A5667F90E4B36D0C39AE44186
// 12300F8DC1435E6390468DC055D5759D1C772D9221188B6EC93AE59783F33644B5FA9952D1F
// 079BA4E6AF253E3EA1505E10DFD1ABEEF74D9D216E690C9CF3A3AF01138B7D69AD0E7155D56
// 630A34A03014FEFBC7750203010001A351304F304D0603551D01044630448010BFB7A1D6CD5
// 289C1A2062A691D4E325EA11E301C311A3018060355040313115075626C6973686572496465
// 6E746974798210491BB8DBE6EBC9914A5ACF0698CC0E18300D06092A864886F70D010104050
// 00381810061476417D94228CAA1003D3A68BF4265DB607A5806BBB48A31AD7726DC73F7BB25
// 04171C5C11BC6903C5D649A05C27640007C7CCF0C32D66E7BB640E353F86CBAC2E74777B379
// 4222F82333933A80F9269EB4AB2319EA519F7F78922066F2C7A47F99286C8B898A5145F0C05
// 6FB82FBD1363472CD8C38E9225FD5CB7CD4520A8"/>
//
// PublisherIdentity was unable to verify the certificate.
//
// This sample completed successfully; press Exit to continue.
#using <System.dll>

using namespace System;
using namespace System::Security;
using namespace System::Security::Policy;
using namespace System::Security::Permissions;
using namespace System::Security::Cryptography::X509Certificates;

// Declarative security requesting evidence of the Publisher.cer 
// X509 certificate.
[assembly: PublisherIdentityPermissionAttribute(
    SecurityAction::RequestMinimum, 
    CertFile = "Publisher.cer")];
public ref class PublisherIdentity
{
public:
    bool DemandCertificate()
    {
        try
        {
            String^ certPath = "Publisher.cer";

            // Create evidence for the Publisher.cer certificate.
            Publisher^ publisher =
                gcnew Publisher(X509Certificate::CreateFromCertFile(certPath));
            Evidence^ evidence = gcnew Evidence();
            evidence->AddHost(publisher);

            // Create an identity permission based on publisher evidence.
            PublisherIdentityPermission^ x509Permission =
                (PublisherIdentityPermission^)
                publisher->CreateIdentityPermission(evidence);

            // Verify that callers higher in the stack have been granted 
            // permission.
            x509Permission->Demand();

            return true;
        }
        catch (SecurityException^ ex)
        {
            Console::WriteLine("An exception was thrown:" + ex->ToString());
        }

        return false;
    }
};

int main()
{
    if ((gcnew PublisherIdentity())->DemandCertificate())
    {
        Console::WriteLine("PublisherIdentity successfully verified " +
            "the certificate.");
    }
    else
    {
        Console::WriteLine("PublisherIdentity was unable to verify the " +
            "certificate.");
    }
}
//
// This sample produces the following output:
//
// An exception was thrown:System.Security.SecurityException: Request for the
// permission of type System.Security.Permissions.PublisherIdentityPermission,
// mscorlib, Version=1.0.5000.0, Culture=neutral, 
// PublicKeyToken=b77a5c561934e089 failed.
//  at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet 
// grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
// PermissionToken permToken)
//  at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
// permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
// checkFrames, Int32 unrestrictedOverride)
//  at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission 
// cap, StackCrawlMark& stackMark)
//  at System.Security.CodeAccessPermission.Demand()
//  at WindowsApplication1.PublisherIdentity.DemandCertificate()

// The state of the failed permission was: 
// <IPermission class="System.Security.Permissions.PublisherIdentityPermission
// ,mscorlib, Version=1.0.5000.0, Culture=neutral, 
//  PublicKeyToken=b77a5c561934e089"
//            version="1"
//            X509v3Certificate="3082020E30820177A0030201020210491BB8DBE6EBC99
// 14A5ACF0698CC0E18300D06092A864886F70D0101040500301C311A30180603550403131150
// 75626C69736865724964656E74697479301E170D3034303232343031303233365A170D33393
// 13233313233353935395A301C311A3018060355040313115075626C69736865724964656E74
// 69747930819F300D06092A864886F70D010101050003818D0030818902818100BF589FB7CD2
// D6DB89EEF6B394A4012B7727AD71EC1E342234DF15391296B5A5667F90E4B36D0C39AE44186
// 12300F8DC1435E6390468DC055D5759D1C772D9221188B6EC93AE59783F33644B5FA9952D1F
// 079BA4E6AF253E3EA1505E10DFD1ABEEF74D9D216E690C9CF3A3AF01138B7D69AD0E7155D56
// 630A34A03014FEFBC7750203010001A351304F304D0603551D01044630448010BFB7A1D6CD5
// 289C1A2062A691D4E325EA11E301C311A3018060355040313115075626C6973686572496465
// 6E746974798210491BB8DBE6EBC9914A5ACF0698CC0E18300D06092A864886F70D010104050
// 00381810061476417D94228CAA1003D3A68BF4265DB607A5806BBB48A31AD7726DC73F7BB25
// 04171C5C11BC6903C5D649A05C27640007C7CCF0C32D66E7BB640E353F86CBAC2E74777B379
// 4222F82333933A80F9269EB4AB2319EA519F7F78922066F2C7A47F99286C8B898A5145F0C05
// 6FB82FBD1363472CD8C38E9225FD5CB7CD4520A8"/>
//
// PublisherIdentity was unable to verify the certificate.
//
// This sample completed successfully; press Exit to continue.
import System.*;
import System.Security.*;
import System.Security.Policy.*;
import System.Security.Permissions.*;
import System.Security.Cryptography.X509Certificates.*;

// Declarative security requesting evidence of the Publisher.cer 
// X509 certificate.
/** @assembly PublisherIdentityPermissionAttribute(SecurityAction.
    RequestMinimum, CertFile = "Publisher.cer")
 */
class PublisherIdentity
{

    /** @attribute STAThread()
     */
    public static void main(String[] args)
    {
        if ((new PublisherIdentity()).DemandCertificate()) {
            Console.WriteLine("PublisherIdentity successfully verified " 
                + "the certificate.");
        }
        else {
            Console.WriteLine("PublisherIdentity was unable to verify the " 
                + "certificate.");
        }
    } //main

    private boolean DemandCertificate()
    {
        boolean blRetVal = false;
        try {
            String certPath = "Publisher.cer";
            // Create evidence for the Publisher.cer certificate.
            Publisher publisher = new Publisher(X509Certificate.
                CreateFromCertFile(certPath));
            Evidence evidence = new Evidence();
            evidence.AddHost(publisher);
            // Create an identity permission based on publisher evidence.
            PublisherIdentityPermission x509Permission 
                = (PublisherIdentityPermission)(
                publisher.CreateIdentityPermission(evidence));
            // Verify that callers higher in the stack have been granted 
            // permission.
            x509Permission.Demand();
            blRetVal = true;
        }
        catch (SecurityException ex) {
            Console.WriteLine("An exception was thrown:" + ex.ToString());
        }
        return blRetVal;
    } //DemandCertificate
} //PublisherIdentity
//
// This sample produces the following output:
//
// An exception was thrown:System.Security.SecurityException: Request for the
// permission of type System.Security.Permissions.PublisherIdentityPermission,
// mscorlib, Version=1.0.5000.0, Culture=neutral, 
// PublicKeyToken=b77a5c561934e089 failed.
// at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet 
// grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
// PermissionToken permToken)
// at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
// permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
// checkFrames, Int32 unrestrictedOverride)
// at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission 
// cap, StackCrawlMark& stackMark)
// at System.Security.CodeAccessPermission.Demand()
// at WindowsApplication1.PublisherIdentity.DemandCertificate()
// The state of the failed permission was: 
// <IPermission class="System.Security.Permissions.PublisherIdentityPermission
// ,mscorlib, Version=1.0.5000.0, Culture=neutral, 
// PublicKeyToken=b77a5c561934e089"
// version="1"
// X509v3Certificate="3082020E30820177A0030201020210491BB8DBE6EBC99
// 14A5ACF0698CC0E18300D06092A864886F70D0101040500301C311A30180603550403131150
// 75626C69736865724964656E74697479301E170D3034303232343031303233365A170D33393
// 13233313233353935395A301C311A3018060355040313115075626C69736865724964656E74
// 69747930819F300D06092A864886F70D010101050003818D0030818902818100BF589FB7CD2
// D6DB89EEF6B394A4012B7727AD71EC1E342234DF15391296B5A5667F90E4B36D0C39AE44186
// 12300F8DC1435E6390468DC055D5759D1C772D9221188B6EC93AE59783F33644B5FA9952D1F
// 079BA4E6AF253E3EA1505E10DFD1ABEEF74D9D216E690C9CF3A3AF01138B7D69AD0E7155D56
// 630A34A03014FEFBC7750203010001A351304F304D0603551D01044630448010BFB7A1D6CD5
// 289C1A2062A691D4E325EA11E301C311A3018060355040313115075626C6973686572496465
// 6E746974798210491BB8DBE6EBC9914A5ACF0698CC0E18300D06092A864886F70D010104050
// 00381810061476417D94228CAA1003D3A68BF4265DB607A5806BBB48A31AD7726DC73F7BB25
// 04171C5C11BC6903C5D649A05C27640007C7CCF0C32D66E7BB640E353F86CBAC2E74777B379
// 4222F82333933A80F9269EB4AB2319EA519F7F78922066F2C7A47F99286C8B898A5145F0C05
// 6FB82FBD1363472CD8C38E9225FD5CB7CD4520A8"/>
//
// PublisherIdentity was unable to verify the certificate.
//
// This sample completed successfully; press Exit to continue.

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

PublisherIdentityPermission-Klasse
PublisherIdentityPermission-Member
System.Security.Permissions-Namespace