{"id":1296,"date":"2013-03-14T16:58:58","date_gmt":"2013-03-14T16:58:58","guid":{"rendered":"http:\/\/nestor.nestasoft.fr\/?p=1296"},"modified":"2013-03-17T04:33:58","modified_gmt":"2013-03-17T04:33:58","slug":"sign-an-assembly-file-in-net-project","status":"publish","type":"post","link":"https:\/\/nestasoft.fr\/?p=1296","title":{"rendered":"Sign an assembly file in .NET project"},"content":{"rendered":"<p>Assemblies are the building blocks of the .NET Framework; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly provides the common language runtime with the information it needs to be aware of type implementations. It is a collection of types and resources that are built to work together and form a logical unit of functionality. To the runtime, a type does not exist outside the context of an assembly [Microsoft Press].<\/p>\n<p>&#160;<\/p>\n<p><strong>Part 1 :&#160; The signature<\/strong><\/p>\n<p>The signature. NET it guaranteed the integrity your original content. The process thus takes its meaning in terms of security and guarantee of authenticity of your program.<\/p>\n<p>In. NET, signing an assembly. Net can be segment it into two components:<\/p>\n<ul>\n<ul>\n<ul>\n<ul>\n<li>The hash of its contents <\/li>\n<li>The strong name <\/li>\n<\/ul>\n<\/ul>\n<\/ul>\n<p>   <strong>Part 2 : The strong name<\/strong><\/ul>\n<ul><strong><\/strong><\/ul>\n<p>There can be more than one component (DLL) with the same naming, but with different versions. This can lead to many conflicts.<\/p>\n<p>A SN Key is used to uniquely identify a component.<\/p>\n<p>&#160;<\/p>\n<p>A strong name is composed of the :<\/p>\n<ul>\n<li>version <\/li>\n<li>Name <\/li>\n<li>Public key <\/li>\n<li>Private key <\/li>\n<li>Culture and CPU architecture <\/li>\n<\/ul>\n<p><strong>Part 3 : Sign an assembly using IDE VS 2010<\/strong><\/p>\n<p><strong><\/strong><\/p>\n<ul>\n<li>1- In the properties of your project check \u00abSign the assembly \u00bb <\/li>\n<\/ul>\n<p><a href=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2013\/03\/Sign1.PNG\"><img loading=\"lazy\" decoding=\"async\" title=\"clip_image002\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"clip_image002\" src=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2013\/03\/Sign1.PNG\" width=\"600\" height=\"362\" \/><\/a><\/p>\n<p>&#160;<\/p>\n<ul>\n<li>2- Enter your key name. <\/li>\n<\/ul>\n<ul>After enter your key name, Visual Studio will generate a key file : yourKeyName.snk<\/ul>\n<p>Your can protect you key name using a password.<\/p>\n<p><a href=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2013\/03\/Sign2.PNG\"><img loading=\"lazy\" decoding=\"async\" title=\"clip_image004\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"clip_image004\" src=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2013\/03\/Sign2.PNG\" width=\"442\" height=\"266\" \/><\/a>&#160;<\/p>\n<p>&#160;<\/p>\n<p><strong><\/strong><\/p>\n<p><strong>Part 4 : Protect your key file with password<\/strong><\/p>\n<p>Enter a passwrod if you don&rsquo;t trust the people with access to the assembly.<\/p>\n<p>In general, you should protect it with a password if you don&rsquo;t trust the people with access to the assembly, which is not common<\/p>\n<p>&#160;<\/p>\n<p><strong><\/strong><\/p>\n<p><strong>Part 5 : Sign an assembly using Al.exe ( Assembly Linker)<\/strong><\/p>\n<ul>\n<li>First step : Create a key file using sn.exe (Strong Name tool) <\/li>\n<\/ul>\n<p><strong><a href=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2013\/03\/Sign3.PNG\"><img decoding=\"async\" title=\"clip_image006\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"clip_image006\" src=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2013\/03\/Sign3.PNG\" \/><\/a><\/strong><\/p>\n<p>Option <strong>-Vf<\/strong> can verifies the strong name contained in assembly <strong>(-vf<\/strong> forces the verifies even if it has been disabled using the <strong>\u2013Vr<\/strong> option).<\/p>\n<p>&#160;<\/p>\n<p><em><\/em><\/p>\n<ul>\n<li>Second step : Sign your assembly using Al.exe <\/li>\n<\/ul>\n<p><a href=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2013\/03\/image.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2013\/03\/image.png\" \/><\/a><\/p>\n<p>&#160;<\/p>\n<p><strong>Part 6 : Sign an assembly&#160; using AssemblyInfo file<\/strong><\/p>\n<p>In the file <strong>AssemblyInfo<\/strong>,&#160; add the <em>AssemblyKeyFileAttribute<\/em> or the <em>AssemblyKeyNameAttribute<\/em>, specifying the name of the file or container that contains the key pair.<\/p>\n<p><a href=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2013\/03\/image_3.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/nestor.nestasoft.fr\/wp-content\/uploads\/2013\/03\/image_3.png\" width=\"409\" height=\"41\" \/><\/a><\/p>\n<p>&#160;<\/p>\n<p><strong><\/strong><\/p>\n<ul>\n<li>If your assembly have a dependency for another assembly (his parent) you must sign it. <\/li>\n<\/ul>\n<p>Stay tuned!<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1296\" class=\"pvc_stats all  \" data-element-id=\"1296\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/nestasoft.fr\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Assemblies are the building blocks of the .NET Framework; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly provides the common language runtime with the information it needs to be aware of type implementations. It is a collection of types and resources that are built to work [&hellip;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1296\" class=\"pvc_stats all  \" data-element-id=\"1296\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/nestasoft.fr\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":1302,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1296","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts\/1296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1296"}],"version-history":[{"count":6,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts\/1296\/revisions"}],"predecessor-version":[{"id":1304,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts\/1296\/revisions\/1304"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/media\/1302"}],"wp:attachment":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}