Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 How to setup your very own Cert-O-Matic Root CA server
3 This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 How to setup your very own Cert-O-Matic Root CA server
9 The program certcgi is part of a small test CA that is used inside
10 Netscape by the NSS development team. That CA is affectionately known
11 as "Cert-O-Matic" or "Cert-O-Matic II". It presently runs on a server
12 named interzone.mcom.com inside Netscape's firewall.
14 If you wish to setup your own Cert-O-Matic, here are directions.
16 Disclaimer: This program does not follow good practices for root CAs.
17 It should be used only for playing/testing and never for production use.
18 Remember, you've been warned!
20 Cert-O-Matic consists of some html files, shell scripts, one executable
21 program that uses NSS and NSPR, the usual set of NSS .db files, and a file
22 in which to remember the serial number of the last cert issued. The
23 html files and the source to the executable program are in this directory.
24 Sample shell scripts are shown below.
26 The shell scripts and executable program run as CGI "scripts". The
27 entire thing runs on an ordinary http web server. It would also run on
28 an https web server. The shell scripts and html files must be
29 customized for the server on which they run.
31 The package assumes you have a "document root" directory $DOCROOT, and a
32 "cgi-bin" directory $CGIBIN. In this example, the document root is
33 assumed to be located in /var/www/htdocs, and the cgi-bin directory in
34 /var/www/cgi-bin.
36 The server is assumed to run all cgi scripts as the user "nobody".
37 The names of the cgi scripts run directly by the server all end in .cgi
38 because some servers like it that way.
40 Instructions:
42 - Create directory $DOCROOT/certomatic
43 - Copy the following files from nss/cmd/certcgi to $DOCROOT/certomatic
44 ca.html index.html main.html nscp_ext_form.html stnd_ext_form.html
45 - Edit the html files, substituting the name of your own server for the
46 server named in those files.
47 - In some web page (e.g. your server's home page), provide an html link to
48 $DOCROOT/certomatic/index.html. This is where users start to get their
49 own certs from certomatic.
50 - give these files and directories appropriate permissions.
52 - Create directories $CGIBIN/certomatic and $CGIBIN/certomatic/bin
53 make sure that $CGIBIN/certomatic is writable by "nobody"
55 - Create a new set of NSS db files there with the following command:
57 certutil -N -d $CGIBIN/certomatic
59 - when certutil prompts you for the password, enter the word foo
60 because that is compiled into the certcgi program.
62 - Create the new Root CA cert with this command
64 certutil -S -x -d $CGIBIN/certomatic -n "Cert-O-Matic II" \
65 -s "CN=Cert-O-Matic II, O=Cert-O-Matic II" -t TCu,cu,cu -k rsa \
66 -g 1024 -m 10001 -v 60
68 (adjust the -g, -m and -v parameters to taste. -s and -x must be as
69 shown.)
71 - dump out the new root CA cert in base64 encoding:
73 certutil -d $CGIBIN/certomatic -L -n "Cert-O-Matic II" -a > \
74 $CGIBIN/certomatic/root.cacert
76 - In $CGIBIN/certomatic/bin add two shell scripts - one to download the
77 root CA cert on demand, and one to run the certcgi program.
79 download.cgi, the script to install the root CA cert into a browser on
80 demand, is this:
82 #!/bin/sh
83 echo "Content-type: application/x-x509-ca-cert"
84 echo
85 cat $CGIBIN/certomatic/root.cacert
87 You'll have to put the real path into that cat command because CGIBIN
88 won't be defined when this script is run by the server.
90 certcgi.cgi, the script to run the certcgi program is similar to this:
92 #!/bin/sh
93 cd $CGIBIN/certomatic/bin
94 LD_LIBRARY_PATH=$PLATFORM/lib
95 export LD_LIBRARY_PATH
96 $PLATFORM/bin/certcgi $* 2>&1
98 Where $PLATFORM/lib is where the NSPR nad NSS DSOs are located, and
99 $PLATFORM/bin is where certcgi is located. PLATFORM is not defined when
100 the server runs this script, so you'll have to substitute the right value
101 in your script. certcgi requires that the working directory be one level
102 below the NSS DBs, that is, the DBs are accessed in the directory "..".
104 You'll want to provide an html link somewhere to the script that downloads
105 the root.cacert file. You'll probably want to put that next to the link
106 that loads the index.html page. On interzone, this is done with the
107 following html:
109 <a href="/certomatic/index.html">Cert-O-Matic II Root CA server</a>
110 <p>
111 <a href="/cgi-bin/certomatic/bin/download.cgi">Download and trust Root CA
112 certificate</a>
114 The index.html file in this directory invokes the certcgi.cgi script with
115 the form post method, so if you change the name of the certcgi.cgi script,
116 you'll also have to change the index.html file in $DOCROOT/certomatic
118 The 4 files used by the certcgi program (the 3 NSS DBs, and the serial
119 number file) are not required to live in $CGIBIN/certomatic, but they are
120 required to live in $CWD/.. when certcgi starts.
122 Known bugs:
124 1. Because multiple of these CAs exist simultaneously, it would be best if
125 they didn't all have to be called "Cert-O-Matic II", but that string is
126 presently hard coded into certcgi.c.
128 2. the html files in this directory contain numerous extraneous <FORM> tags
129 which appear to use the post method and have action URLS that are never
130 actually used. burp.cgi and echoform.cgi are never actually used. This
131 should be cleaned up.
133 3. The html files use <layer> tags which are supported only in Netscape
134 Navigator and Netscape Communication 4.x browsers. The html files do
135 not work as intended with Netscape 6.x, Mozilla or Microsoft IE browsers.
136 The html files should be fixed to work with all those named browsers.