Log in

View Full Version : StrongNameIdentityPermission


SHaG
July 3rd, 2007, 08:23
Hey,

Been some time since I touched .NET executables and it seems some things have changed....

While trying to use a dll in my app i ran into this error:
"Request for StrongNameIdentityPermission failed".
Tried the old trick of setting SN signature length to 0 - didn't do it. Tried to exclude it from SN check by running sn /Vr - no result either...

Can someone please point me in the right direction?

disavowed
July 3rd, 2007, 23:28
http://www.woodmann.com/forum/showthread.php?t=9926

SHaG
July 4th, 2007, 03:51
Basically, the assembly in question was not strong-signed. Instead it used the mechanism described below to prevent calls from non-trusted / signed code:

http://www.morganskinner.com/Articles/StrongNameIdentityPermission/

When compiled with attribute

[StrongNameIdentityPermission(SecurityAction.LinkDemand, PublicKey="0024..."]

the disassembly contains this permission block

.permissionset linkcheck = (3C 00 50 00 65 00 72 00 6D 00 69 00 73 00 73 00 // <.P.e.r.m.i.s.s.
69 00 6F 00 6E 00 53 00 65 00 74 00 20 00 63 00 // i.o.n.S.e.t. .c.
6C 00 61 00 73 00 73 00 3D 00 22 00 53 00 79 00 // l.a.s.s.=.".S.y.
73 00 74 00 65 00 6D 00 2E 00 53 00 65 00 63 00 // s.t.e.m...S.e.c.
75 00 72 00 69 00 74 00 79 00 2E 00 50 00 65 00 // u.r.i.t.y...P.e.
72 00 6D 00 69 00 73 00 73 00 69 00 6F 00 6E 00 // r.m.i.s.s.i.o.n.
...

Removing it and reassembling the assembly is enough to prevent StrongNameIdentityPermission from being checked.

I guess that if the assembly also was strong-named it would have to be resigned...