Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Reading the public key inside a strongly signed assembly from the assembly itself???

Reply
Thread Tools

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

 
 
Bob Rock
Guest
Posts: n/a
 
      05-16-2004
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


 
Reply With Quote
 
 
 
 
Nicole Calinoiu
Guest
Posts: n/a
 
      05-16-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Michel Gallant
Guest
Posts: n/a
 
      05-16-2004
AssemblyName assemname = Assembly.LoadFrom(<assemblyfile>).GetName() ;
byte[] pubkey = assemname.GetPublicKey() ;

- Mitch

"Bob Rock" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSE 4 11-15-2006 02:40 AM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola Microsoft Certification 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSD 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd realexxams@yahoo.com Microsoft Certification 0 05-10-2006 02:35 PM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM



Advertisments