[quoted text, click to view] "ed" <ed@discussions.microsoft.com> wrote in message
news:C71C364B-E24B-49F3-8D8B-9771810BEDA8@microsoft.com...
> Hello,
> I have the following situation:
> Assembly A.dll have some routine inside that application B.exe uses. I
> waht
> to prevent other people from loading A.dll and call the method with the
> routine.
>
> For that, I make A.dll and B.dll strong named, and the method
> "String SensitiveRoutine()" have the StrongNameIdentityPermission
> attribute
> with the pulic key of B.exe, I set the security action to Demand.
>
> and I receive this secutiry error:
> Request for the permission of type
> System.Security.Permissions.StrongNameIdentityPermission, mscorlib,
> Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
> failed.
This is to be expected in most cases since their is often some .NET
Framework code (which is not signed with your strong naming key) on the call
stack. Link demands are usually used for identity permission demands to
prevent exactly this issue.
[quoted text, click to view] > If I set the security action to LinkDemand I don't receive the error, but
> other application C.exe with different public key can call the method!
This is not expected behaviour under version 1.1 of the .NET Framework. Are
you calling SensitiveRoutine directly from C.exe, or is the call being made
by invoking a method in A.dll or B.dll that then invokes SensitiveRoutine?
[quoted text, click to view] > If I put the attribute at assembly level
> [assembly:StrongNameIdentityPermissionAttribute........] with
> RequestMinimum
> as security action, it does't work.
Assembly-level permission attributes affect only the assembly in which they
appear. They have no impact whatsoever on demands placed on callers from
other assemblies, so the behaviour you describe is to be expected.
[quoted text, click to view] > what should I do to ensure that the code that call the sensitive routine
> is
> one from the strong named assemblies that I signed before?
That depends by what you mean by "ensure". Highly privileged code can
bypass any identity permission even under v. 1.1. In v. 2.0, fully trusted
code will automatically pass all identity permission demands, so your SNIP
attribute will provide even less protection there. If you want to more
effectively screen callers, a licensing scheme may be more effective.
However, this wouldn't offer substantial protection against a determined and
highly privileged attacker, so it may or may not be worth the trouble of
implementing in your particular case.