Reading the public key inside a strongly signed assembly from the assembly itself???

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Reading the public key inside a strongly signed assembly from the assembly itself???

    Hello,

    is it possible to programmatically read (and how) the public key that is
    embedded into an assembly that has been strongly signed???
    What code would be needed???

    Bob Rock


    Bob Rock Guest

  2. Similar Questions and Discussions

    1. Problem using an assembly
      I have a User Control that I created (.ascx & .ascx.vb file pair) that I am trying to put in a separate assembly. I know that the User Control works...
    2. Assembly acessing StrongNamed assembly getting "Access Denied" intermitently
      I have an ASP.NET application that is using a code library our development team uses. The code library is a few web controls in a Strong Named...
    3. Signed assembly will not load in internet explorer
      I've got an assembly that implements a class that inherits System.Windows.Forms.UserControl. This works wonderfully when I embed it in an ASP.NET...
    4. Strongly Named Assemblies - how do you create an installation that allows an assembly key to be trusted?
      We are publishing Winform controls in some of our WebForms. Our Assembly is strongly named, and we would like to create an installation that would...
    5. GAC assembly with ASP.NET
      There's no need to put your Class Library in the GAC, give it a strong name, etc., BTW. You can just put a copy of the DLL in the /bin folder of...
  3. #2

    Default Re: Reading the public key inside a strongly signed assembly from the assembly itself???

    Bob,

    The method below returns the key (if one is found) from any type's assembly.
    To use it to retrieve the current assembly's key, call it as follows
    (assuming you're calling from the class in which the method is declared):

    StrongNamePublicKeyBlob myKey = this.GetSigningKey(this.GetType());

    HTH,
    Nicole


    public StrongNamePublicKeyBlob GetSigningKey(Type sourceType)
    {
    if (sourceType == null) throw new ArgumentNullException("sourceType");

    StrongNamePublicKeyBlob retVal = null;

    foreach (object test in sourceType.Assembly.Evidence)
    {
    if (test is StrongName)
    {
    retVal = ((StrongName)test).PublicKey;
    break;
    }
    }

    return retVal;
    }

    "Bob Rock" <nospam.yet_another_apprentice@hotmail.com> wrote in message
    news:2gpreqF5hhuoU1@uni-berlin.de...
    > Hello,
    >
    > is it possible to programmatically read (and how) the public key that is
    > embedded into an assembly that has been strongly signed???
    > What code would be needed???
    >
    > Bob Rock
    >
    >

    Nicole Calinoiu Guest

  4. #3

    Default Re: Reading the public key inside a strongly signed assembly from the assembly itself???

    AssemblyName assemname = Assembly.LoadFrom(<assemblyfile>).GetName() ;
    byte[] pubkey = assemname.GetPublicKey() ;

    - Mitch

    "Bob Rock" <nospam.yet_another_apprentice@hotmail.com> wrote in message
    news:2gpreqF5hhuoU1@uni-berlin.de...
    > Hello,
    >
    > is it possible to programmatically read (and how) the public key that is
    > embedded into an assembly that has been strongly signed???
    > What code would be needed???
    >
    > Bob Rock
    >
    >

    Michel Gallant Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139