I have two C# .Net projects TestApplication.exe and Secure.dll. I signed my application with key generated by sn.exe utility and exported the public key to be used in dll.
I called TestStrongNameIDentityPermission from my TestApplication with different parameters.
It is my understanding that the function call should fail if the version/strongname or key is different.
No matter what parameters i pass the function call always succeeds. I even changed public key it suceeds.
Why is that the call always succeeds. ?
TIA
publicbool TestStrongNameIDentityPermission(string strongname ,string version )
{
try
{
byte[] publickey = { 40, 33, 0, 0, 4, 127, 0, 0, 148, 0, 0, 0, 6, 2, 0, 0, 0, 36, 0, 0, 82, 8, 65, 49, 0, 14, 0, 0, 1, 90, 1, 0, 213, 248, 67, 47, 139, 83, 44, 205, 34, 104, 199, 139, 110, 202, 187, 66, 108, 119, 143, 159, 174, 113, 197, 190, 15, 237, 156, 140, 113, 228, 169, 56, 153, 53, 167, 106, 10, 75, 201, 53, 72, 112, 179, 73, 214, 239, 53, 192, 101, 170, 135, 20, 238, 42, 186, 210, 225, 183, 102, 245, 253, 80, 139, 83, 172, 187, 212, 222, 13, 10, 112, 80, 130, 219, 246, 60, 131, 101, 190, 18, 253, 81, 81, 50, 33, 115, 77, 239, 194, 214, 28, 56, 42, 252, 48, 254, 172, 5, 222, 107, 19, 203, 74, 196, 153, 137, 193, 109, 40, 175, 7, 24, 128, 138, 129, 189, 14, 254, 161, 20, 153, 13, 188, 114, 135, 25, 233, 200 };
StrongNamePublicKeyBlob publickeyblob =newStrongNamePublicKeyBlob (publickey);
System.Version ver = newVersion(version);
StrongNameIdentityPermission sip =newStrongNameIdentityPermission(publickeyblob,strongname,ver);
sip.Demand();
returntrue ;
}
catch(SecurityException se)
{
Console.WriteLine ("Identity Permission Failed -- Strong Name "+ strongname +"--version -- "+ version );
Console.WriteLine (se.StackTrace );
returnfalse;
}
}