11.07.2015 Views

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

198 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>s To extract a public key from an assembly●Run the following comm<strong>and</strong> to obtain a hex representation of a public key from anassembly:secutil -hex -strongname yourassembly.dll To extract the public key from a key pair file1. Generate the key pair file with the following comm<strong>and</strong>:sn -k keypairfile2. Extract the public key from the key pair file:sn -p keypairfile publickeyfile3. Obtain a hex representation of the public key:sn -tp publickeyfile > publickeyhex.datRestrict InheritanceIf your class is designed as base class, you can restrict which other code is allowedto derive from your class by using an inheritance dem<strong>and</strong> coupled with aStrongNameIdentityPermission as shown in the following example. This preventsinheritance of your class from any assembly that is not signed with the private keycorresponding to the public key in the dem<strong>and</strong>.// The following inheritance dem<strong>and</strong> ensures that only code within the// assembly with the specified public key (part of the assembly's strong// name can sub class SomeRestrictedClass[StrongNameIdentityPermission(<strong>Security</strong>Action.InheritanceDem<strong>and</strong>,PublicKey="00240000048...97e85d098615")]public class SomeRestrictedClass{}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!