You can run django-ca as a regular app in any existing Django project of yours, but if you don’t have any Django project running, you can run it as a standalone project.

Another easy way of running django-ca is as a Docker container.


  • Python 2.7 or Python 3.4+

  • Django 1.11+

  • Any database supported by Django (sqlite3/MySQL/PostgreSQL/…)

  • Python, OpenSSL and libffi development headers

If you’re using an older system, you can consult this table to see what versions of Python, Django and cryptography where tested with what release (changes to previous versions in bold):







2.7/3.4 - 3.6

1.8 - 1.10



2.7/3.4 - 3.6

1.8 - 1.11



2.7/3.4 - 3.6

1.8, 1.10 - 1.11



2.7/3.4 - 3.6

1.8, 1.10 - 2.0

2.1 - 2.2


2.7/3.4 - 3.6

1.11 - 2.0

2.1 - 2.2


2.7/3.4 - 3.6

1.11 - 2.1

2.1 - 2.3


2.7/3.4 - 3.7

1.11 - 2.1

2.1 - 2.3


2.7/3.4 - 3.7

1.11 - 2.1

2.1 - 2.4

2.6 - 2.8


2.7/3.5 - 3.7

1.11, 2.1 - 2.2

2.2 - 2.6

2.6 - 2.8

As Django app (in your existing Django project)

This chapter assumes that you have an already running Django project and know how to use it.

You need various development headers for pyOpenSSL, on Debian/Ubuntu systems, simply install these packages:

$ apt-get install gcc python3-dev libffi-dev libssl-dev

You can install django-ca simply via pip:

$ pip install django-ca

and add it to your INSTALLED_APPS:

   # ... your other apps...


… and configure the other available settings to your liking, then simply run:

$ python migrate
$ python collectstatic

# FINALLY, create the root certificates for your CA:
#     (replace parameters after init_ca with your local details)
$ python init_ca RootCA \
>     /C=AT/ST=Vienna/L=Vienna/O=Org/OU=OrgUnit/

After that, django-ca should show up in your admin interface (see Web interface) and provide various commands (see Command-line interface).

As standalone project

You can also install django-ca as a stand-alone project, if you install it via git. The project provides a command-line interface that provides complete functionality. The web interface is optional.


If you don’t want the private keys of your CAs on the same machine as the web interface, you can also host the web interface on a second server that accesses the same database (CA private keys are hosted on the filesystem, not in the database). You obviously will not be able to sign certificates using the web interface, but you can still e.g. revoke certificates or run a OCSP responder.

In the following code-snippet, you’ll do all necessary steps to get a basic setup:

# install dependencies (adapt to your distro):
$ apt-get install gcc git python3-dev libffi-dev libssl-dev virtualenv

# clone git repository:
$ git clone

# create virtualenv:
$ cd django-ca
$ virtualenv -p /usr/bin/python3 .
$ source bin/activate

# install Python dependencies:
$ pip install -U pip setuptools
$ pip install -r requirements.txt

In the above script, you have created a virtualenv, meaning that all libraries you install with pip install are installed in the virtualenv (and don’t pollute your system). It also means that before you execute any commands, you’ll have to activate your virtualenv, by doing, in the directory of the git checkout:

$ source bin/activate

Configure django-ca

Before you continue, you have to configure django-ca. Django uses a file called, but so you don’t have to change any files managed by git, it includes in the same directory. So copy the example file and edit it with your favourite editor:

$ cp ca/ca/ ca/ca/

The most important settings are documented there, but you can of course use any setting provided by Django.


The SECRET_KEY and DATABASES settings are absolutely mandatory. If you use the Web interface, the STATIC_ROOT setting is also mandatory.

Initialize the project

After you have configured django-ca, you need to initialize the project by running a few commands:

$ python ca/ migrate

# If you intend to run the webinterface (requires STATIC_ROOT setting!)
$ python ca/ collectstatic

# FINALLY, create a certificate authority:
#     (replace parameters after init_ca with your local details)
$ python init_ca RootCA /C=AT/ST=Vienna/L=Vienna/O=Org/

Please also see Certificate authority management for further information on how to create certificate authorities. You can also run init_ca with the -h parameter for available arguments.

Create shortcut

If you don’t want to always chdir to the git checkout, activate the virtualenv and only then run, you might want to create a shortcut shell script somewhere in your PATH (e.g. /usr/local/bin):


# BASEDIR is the location of your git checkout

${PYTHON} ${MANAGE} "$@"

Setup a webserver

Setting up a webserver and all that comes with it is really out of scope of this document. The WSGI file is located in ca/ca/ Django itself provides some info for using Apache and mod_wsgi, or you could use uWSGI and nginx, or any of the many other options available.

Apache and mod_wsgi

Github user Raoul Thill notes that you need some special configuration variable if you use Apache together with mod_wsgi (see here):

WSGIDaemonProcess django_ca processes=1 python-path=/opt/django-ca/ca:/opt/django-ca/ca/ca:/opt/django-ca/lib/python2.7/site-packages threads=5
WSGIProcessGroup django_ca
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /opt/django-ca/ca/ca/

Regular cronjobs

Some commands are intended to be run as cronjobs:

# assuming you cloned the repo at /root/:

# m h  dom mon dow      user  command

# notify watchers about certificates about to expire
* 8    * * *            root  python ca/ notify_expiring_certs

# recreate the CRL and the OCSP index
12 *    * * *           root  python ca/ dump_crl
14 *    * * *           root  python ca/ dump_ocsp_index