README.rst 5.43 KB
Newer Older
ale's avatar
ale committed
1

ale's avatar
ale committed
2
=====================================================
ale's avatar
ale committed
3 4 5
cam - minimal X509 Certification Authority management
=====================================================

ale's avatar
ale committed
6 7 8
``cam`` is a tiny Python program that can be used to manage a X509
Certification Authority for a small organization. It can only create
server certificates, so it is not going to be useful to manage an
ale's avatar
ale committed
9 10 11
X509-based client authentication infrastructure.

The intended usage involves describing the list of certificates to
ale's avatar
ale committed
12
generate in a configuration file, and using the ``cam`` tool to create
ale's avatar
ale committed
13 14 15
and renew them.


ale's avatar
ale committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29
Installation
------------

``cam`` has few requirements:

* A moderately recent version of Python 2;
* OpenSSL (>=1.0.0) - specifically, the ``openssl`` binary.

Once you have downloaded the source code, system-wide installation is
simply a matter of::

    $ sudo python setup.py install


ale's avatar
ale committed
30 31 32
Configuration
-------------

ale's avatar
ale committed
33 34 35 36
The configuration file uses a standard INI-like syntax, consisting of
a number of sections. There are two special sections: ``ca`` and
``global``, any other section is interpreted as a certificate
definition.
ale's avatar
ale committed
37

ale's avatar
ale committed
38
The ``ca`` section contains the attributes of the CA itself, see the
ale's avatar
ale committed
39 40
example configuration file to see which attributes are supported.

ale's avatar
ale committed
41 42 43
The ``global`` section contains configuration parameters for ``cam``.
The only configuration parameter supported is ``root_dir``, which is
where all the CA private data will be stored.
ale's avatar
ale committed
44

ale's avatar
ale committed
45
Certificates are identified by a *tag* (the section name), so for
ale's avatar
ale committed
46 47 48 49 50 51 52 53 54
example given the following configuration snippet::

    [web]
    cn = www.domain.org

you would use the following command to generate it::

    $ cam --config=my.config gen web

ale's avatar
ale committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159

Global
++++++

The ``global`` section contains options that affect the behavior of
the ``cam`` tool itself. You can usually leave this out altogether.

Available options:

``root_dir``
  This is where the CA private data will be stored. If you leave this
  parameter empty, or if you don't define a ``global`` section at all,
  this will default to the directory containing the configuration file.


Certification Authority
+++++++++++++++++++++++

The ``ca`` section specifies parameters for the Certification
Authority. Some of these are mandatory as they uniquely identify each
CA.

The following parameters specify options of the CA certificate itself.
They are only used once, at CA initialization time (when running ``cam
init``). Subsequent changes to these options will be ignored.

``cn``
  Value of the Common Name (CN) field in the X509 Subject.

``org``
  Value of the Organization (O) field in the X509 Subject.

``country``
  Value of the Country (C) field in the X509 Subject.

``email``
  Contact email, added to the X509 CA certificate.

``days``
  Number of days that the CA certificate will be valid for (default:
  3650, or 10 years).

``crl_url``
  Public URL where the CA Certificate Revocation List will be
  accessible (optional).

Other options:

``default_days``
  Number of days that a new certificate will be valid for (default: 365).

``bits``
  Size of the RSA key for the CA certificate, and also default key
  size for all newly created certificates (default: 2048).

``signature_algorithm``
  Digest algorithm to use for CA signatures (default: sha256).


Certificates
++++++++++++

Every other section defines options for a certificate. Some of these
options can be left unset, in which case a default value will be
provided by the ``ca`` section. ``cn`` must be always specified.

The following options are available:

``days``
  Number of days that this certificate will be valid for. If unset,
  will use ``ca.default_days``.

``cn``
  Common Name (CN) for the X509 Subject.

``ou``
  Organizational Unit (OU) for the X509 Subject (optional).

``alt_names``
  Space-separated list of alternate names for this certificate. These
  will be encoded as DNS entries in the certificate's X509v3 Subject
  Alternative Name field.


Usage
-----

Once you have created a configuration file, initialize the CA by
running::

    $ cam --config=my.config init

This will create the CA certificate and private key, and it will ask
you to set a passphrase for the key. Pick something secure.

Once this is done, you will be able to generate the certificates
described in the configuration using the ``cam gen`` command. For
example, if the configuration defines a certificate with a tag of
``web``::

    $ cam --config=my.config gen web

The tool will ask you for the CA passphrase, and it will create a
certificate and a private key in the CA private data directory. You
can obtain their path with::
ale's avatar
ale committed
160 161 162 163 164

    $ cam --config=my.config files web
    /your/ca/dir/public/certs/web.pem
    /your/ca/dir/private/web.key

ale's avatar
ale committed
165 166 167
At any time you can inspect the status of the configured certificates
(and see which ones are about to expire) using the ``cam list``
command::
ale's avatar
ale committed
168

ale's avatar
ale committed
169 170 171 172 173
    $ cam --config=my.config list


Standalone Install
------------------
ale's avatar
ale committed
174 175

The CA private keys are very sensitive information, so you'll want to
ale's avatar
ale committed
176 177
store them in some encrypted removable storage. You can bundle the
``cam`` application itself with the CA data by using ``virtualenv``::
ale's avatar
ale committed
178 179 180

    $ virtualenv --no-site-packages /secure/cam
    $ virtualenv --relocatable /secure/cam
181
    $ (cd /tmp ; git clone https://git.autistici.org/ai/cam.git \
ale's avatar
ale committed
182 183 184 185 186 187 188 189 190
       && /secure/cam/bin/python setup.py install)

Then you can simply mount your encrypted image wherever there is a
Python interpreter available (well, with the same architecture/OS too)
and run::

    $ /secure/cam/bin/cam --config=/secure/ca/my.config ...