Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Security (http://www.velocityreviews.com/forums/f62-asp-net-security.html)
-   -   Reading the public key inside a strongly signed assembly from the assembly itself??? (http://www.velocityreviews.com/forums/t766105-reading-the-public-key-inside-a-strongly-signed-assembly-from-the-assembly-itself.html)

Bob Rock 05-16-2004 06:49 PM

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



Nicole Calinoiu 05-16-2004 07:21 PM

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




Michel Gallant 05-16-2004 08:35 PM

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





All times are GMT. The time now is 08:47 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


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