473,804 Members | 3,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Signing Assemblies with Key File (snk) Practices

I wish to know the industrial practices for signing
assemblies with key files.

I genereted a key file to sign my assemblies.

Should I sign all my assemblies with a single key files
or I shall generate one key file for each assembly?

Perhaps, I should generate a key file per group of
related assemblies?

Please advice
Jul 21 '05 #1
3 10709
Hi Joel,

All assemblies you produce can use the same public and private keys as long
as the assemblies
have unique friendly text names.

Next, you need to associate the 1,024-bit public key with an assembly. You
do this by telling the
compiler to read the contents of a key file, extract the public key from the
key file, and place the
public key into the definition of the assembly's identity. In effect, this
makes the public key an
extension of the friendly text name of the assembly. This also makes the
assembly name globally
unique because no other developer will be using the same 1,024-bit public
key as part of their assemblies' name.

You can know more about key files and how to generate them on the following
link:
[/keyfile]
http://msdn.microsoft.com/library/de...ifykeyfile.asp
HTH

Mona


"Joel Leong" <ch******@time. net.my> wrote in message
news:10******** *************** *****@phx.gbl.. .
I wish to know the industrial practices for signing
assemblies with key files.

I genereted a key file to sign my assemblies.

Should I sign all my assemblies with a single key files
or I shall generate one key file for each assembly?

Perhaps, I should generate a key file per group of
related assemblies?

Please advice

Jul 21 '05 #2
I would recommend that you generate a single key file for each solution
where the key files are used by the projects within the solution.
If you have assemblies that you re-use across projects:
There are two ways to reuse a project:
a) to include the code in another solution
b) to reference the compiled dll

if you are using (a) in your solutions, then I use the following logic:
a.1) if all of your projects are under a single source tree, then place
the key file closer to the root of the source tree, so that it is in a
directory that is a common ancestor to all of your source directories. That
way, your reference to the key file can still be a relative reference.
a.2) if your shared library is not in a common source tree but you still
intend to share source, place the key file in the same directory as the
AssemblyInfo file.

if you are using (b) in your solutions:
b.1) if all of the projects using the same key file are related, then
use (a.1).
b.2) If the projects are unrelated, use (a.2)

In your assemblyinfo.cs file, ALWAYS use a relative path location. I know
it is a hassle to put in a filename like
"..\..\..\..\.. \..\..\..\..\ke yfile.snk" However, doing so will allow the
code to be compiled on any developer's workstation simply by fetching the
entire source tree from version control. (this includes for build
machines). If you code "C:\a\b\c\keyfi le.snk" and get the source tree onto
the D: drive of a build machine, none of your projects will compile.
Depending on what was on that machine before the compile was initiatited,
the error messages that appear can be anywhere from small (a few lines
pointing at the assemblyinfo file) to severe (hundreds of lines of errors
because an obsolete version of one or more common dlls was on the target
machine).

do not share key files between projects.

Note that key files are used to sign assemblies for the GAC. If you would
also like to sign controls for download to IE, you will need a different set
of procedures. The procedures above are for signing for the GAC and nothing
more.

HTH
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Joel Leong" <ch******@time. net.my> wrote in message
news:10******** *************** *****@phx.gbl.. .
I wish to know the industrial practices for signing
assemblies with key files.

I genereted a key file to sign my assemblies.

Should I sign all my assemblies with a single key files
or I shall generate one key file for each assembly?

Perhaps, I should generate a key file per group of
related assemblies?

Please advice

Jul 21 '05 #3
Joel Leong wrote:

I talk about signing files on the third section of my fusion workshop
(http://www.grimes.demon.co.uk/workshops/fusionWS.htm).
I wish to know the industrial practices for signing
assemblies with key files.

I genereted a key file to sign my assemblies.

Should I sign all my assemblies with a single key files
or I shall generate one key file for each assembly?

Perhaps, I should generate a key file per group of
related assemblies?


Look at the purpose for the key pair:

1) gives your assemblies a strong name
2) associates the assemblies as coming from the same publisher
3) signs your assemblies to prevent tampering

The use in the strong is that the key is unique and hence the assembly name
is unique, so if another assembly uses your library Fusion knows that it
should load *exactly* the right version, no other version will do. Since you
generate the key pair, the pair is associated with you. This does not say
who you are (a vertificate will do that) but it does say that if you
published assembly X with a key, and the user has an assembly Y signed with
the same key, then Y was also written by you. This is important because your
users could decide that they want to trust all assemblies from you and so
this is quite simple to do: trust all assembleis with the same public key.
When your assembly is signed a hash of the assembly is signed with the
private key and stored in the assembly along with the public key, so when
the assembly is loaded the hash is generated again and compared with the
hash stored in the assembly after it is decrypted with the publis key. If
the two hashes are different then the assembly has been tampered with since
it was published, and so it is not loaded.

So my advice is to have a *single* key pair for *all* the assemblies you
write. Keep that key pair safe (use delay signing if necessary
http://www.grimes.demon.co.uk/worksh...m#Example_3_8). That
way a user will be able to trust all of your assemblies. If you have lots
and lots of keys (one key per application, or a key for a group of
assemblies) then the keys are no longer useful as a way to identify the
publisher.

Richard
--
www.richardgrimes.com
my email ev******@zicf.b et is encrypted with ROT13 (www.rot13.org)
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1722
by: Tom Dacon | last post by:
If you're not putting assemblies in the GAC, but are referencing shared code with copylocal=true into the projects that use them, is there any value to signing the assemblies? In the environment I've just begun to work in, there are customer-facing web sites, internally-accessed maintenance and admin web sites, middle-tier business logic assemblies, services, and Windows Forms apps that run on the middle-tier. The policy is to sign the...
1
1259
by: serge calderara | last post by:
Dear all, I have different asseblies that I would like to sign in order to place them in the GAC. For that I first create a keypair at the same place as my solution file with : sn -k lang.snk Then in my assemblyInfo file I place following line: <Assembly: AssemblyKeyFileAttribute("lang.snk")>
9
4184
by: Invalidlastname | last post by:
Hi, We developed some assemblies which use EnterpriseServices queued components. In order to use EnterpriseServices, these assemblies need to be installed into GAC. I used the pre-build and post-build events to automate GAC installation processes and the asp.net application has "copy to local" set to false for the references of these shared assemblies. However, every time we made the changes to the shared assemblies, we had to restart...
0
1063
by: Jonas Blunck | last post by:
Hi all, I'd like to sign an ASP.NET assembly with our private/public key pair when I build it in VS (not by using al from the commandline). I've added the AssemblyKeyFile attribute in AssemblyInfo.cs, just like you normaly do with other project types. When I compile, for some reason, the compiler attempts to load the snk file relative to
3
356
by: Joel Leong | last post by:
I wish to know the industrial practices for signing assemblies with key files. I genereted a key file to sign my assemblies. Should I sign all my assemblies with a single key files or I shall generate one key file for each assembly? Perhaps, I should generate a key file per group of related assemblies?
1
14517
by: Jason Richmeier | last post by:
I have encountered an error while attempting to sign an assembly. I have become quite frustrated since I seem to be going in circles and making no progress. Hopefully someone will have the magic answer. I am new to this so I will try to describe everything as well as I can. There are probably a number of things that I am doing wrong so I will try to desribe the errors that I am receiving along with things that I have tried and...
3
1371
by: Janiek Buysrogge | last post by:
Hi, In my ActiveX component, which is written in .NET, I use a couple of GUI libraries I found on the net, with nicer group boxes and buttons. For using .NET assemblies as ActiveX components you must register them for COM and then add them to the GAC (I'm sure many people know this) I can sign my own assemblies before I add them with gacutil, but what about these dll's I don't have the source of ? I can't sign these and
6
1436
by: Larry | last post by:
When compiling, i get the following error. Preparing resources... Updating references... Performing main compilation... vbc : error BC30145: Unable to emit assembly: Referenced assembly 'Interop.THEDLLNAME' does not have a strong name Building satellite assemblies... Satellite assemblies could not be built because the main project output is missing.
6
5686
by: raylopez99 | last post by:
Anybody use Strong Name Signing? I think this is used by default for Resource files, which is one reason perhaps I can't get my resource files to work (somehow the public key is messed up, perhaps since I've installed so many versions of Visual Studio) RL http://msdn.microsoft.com/en-us/library/h4fa028b.aspx Deployment in Visual Studio
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.