**** Merged from MCS ****
[mono-project.git] / mcs / tools / security / README
blobfb64955407c15bd113eef7d656f6cc3a7bbb6e2a
1 Mono's Security Tools - README
2 Last updated: February 24, 2004 (post mono 0.30)
4 * General notes
6 - This directory contains clones for .NET security tools;
7 - All tools are 100% managed code with no dependency to the Mono's runtime.
8 - A much as possible the same command line arguments as the original are used;
9 - Documentation (man) is available for most tools;
10 - All tools, except secutil.exe, requires the Mono.Security.dll assembly.
11 - Authenticode(r) support is MINIMAL - there are still many missing
12   validations.
15 * Known bugs
17 - If signcode.exe is executed more than once on a assembly, the signature 
18 becomes invalid (but the assembly can still be executed).
21 * Authenticode tutorial
23 1.    Getting a test certificate
25 The tool makecert.exe can create test certificates. The test certificates are
26 only trusted by Mono's security tools (i.e. the resulting signature won't be
27 valid on Windows [1]). For "real" certificates you must deal with (and pay) a
28 trusted commercial CA (or you can have your own CA inside your entreprise).
30 The command:
31 mono makecert.exe -n "CN=your name" -sv yourkeypair.pvk yourcert.cer
33 will create both a PVK file (containing your private key) and a CER file
34 (containing the X.509 certificate). This step will take some time because the
35 tools must generate your own keypair (in this case a 1024 bits RSA keypair).
37 example:
38 mono makecert.exe -n "CN=Sebastien Pouliot" -sv spouliot.pvk spouliot.cer
41 2.    Getting a SPC file
43 The certificate file (.cer) must be converted into a SPC (software publisher
44 certificate) file before signing any assembly (or executable file).
46 The command:
47 mono cert2spc.exe yourcert.cer yourspc.spc
49 will create your SPC file from your X.509 certificates files.
51 example:
52 mono cert2spc.exe spouliot.cer spouliot.spc
55 3.    Signing an assembly
57 You need both your PVK (private key) and SPC files to sign an assembly (or
58 any PE file). You may also include a countersignature in your assembly using 
59 a timestamp server (so the signature can still be verified after your 
60 certificate is expired).
62 The command:
63 mono signcode.exe -v yourkeypair.pvk -spc yourspc.spc -t
64 http://timestamp.verisign.com/scripts/timstamp.dll yourassembly.exe
66 will sign the specified PE file using your private key and embed your 
67 certificate and a timestamp. Note: there are no "e" in timstamp.dll !
69 example:
70 mono signcode.exe -v spouliot.pvk -spc spouliot.spc -t
71 http://timestamp.verisign.com/scripts/timstamp.dll small.exe
74 4.    Checking an assembly
76 Anyone can now validate the assembly signature using the chktrust tool.
78 The command:
79 mono chktrust.exe yourassembly.exe
81 will verify the integrity of the specified PE file. Any change to the file
82 will invalidate it's signature.
84 example:
85 mono chktrust.exe small.exe
89 [1] FOR TEST PURPOSE ONLY ON WINDOWS
91 As stated you can "activate" the Mono's test certificate by doing the 
92 following steps.
94 a.      Generate the Mono's root certificate
95         mono makecert.exe -r mono.cer
96 b.      Double-click on the mono.cer file
97 c.      Click on the "Install certificate..." button
98 d.      Read everything then, if you still want to, answer YES to add the test
99         certificate in your TRUSTED root certificates.
101 Be warned that by doing so YOU ARE TRUSTING THIS TEST CERTIFICATE on your
102 system. This is bad for several reason, foremost that EVERYONE has access to 
103 it's private key! Please remove the test certificate AS SOON as you have 
104 finished testing using it.
106 --------------------
107 sebastien@ximian.com