RETIRED - An Ephemeral PKI system that can act as a trust anchor for OpenStack PKI operations
Go to file
Tim Kelsey e6e091f761 Adding Bandit gate test scaffolding
Initial bits n bobs to get a working Bandit test env for tox, we
can tweek this going forward to tune our test Bandit tests etc

This is not run as part of the normal tox command, run it with
tox -e bandit

Change-Id: I257b0ac335929ad09c43f5753feaab10c269d232
2015-04-17 09:25:29 +01:00
CA Move CA stuff into a dir 2014-03-21 14:04:20 +00:00
anchor Added tests to bring coverage up to 100% of validators 2015-04-14 14:48:03 +00:00
bin Refactored for name change from 'Ephemeral CA' to 'Anchor' 2014-12-01 13:22:51 +00:00
certs Add serial number handling 2014-03-21 14:30:23 +00:00
tests Added tests to bring coverage up to 100% of validators 2015-04-14 14:48:03 +00:00
tools Adding run_tests.sh following OpenStack Standards 2015-02-17 12:29:04 -08:00
.gitignore Bringing Anchor project setup inline with OpenStack 2015-01-08 14:20:38 +00:00
.gitreview Updated .gitreview file. 2014-12-02 12:09:47 +00:00
.testr.conf Bringing Anchor project setup inline with OpenStack 2015-01-08 14:20:38 +00:00
MANIFEST.in Include config in source release 2014-03-28 10:59:23 +00:00
README.md Change default config to validate only example.com 2015-02-17 10:58:42 -08:00
bandit.yaml Adding Bandit gate test scaffolding 2015-04-17 09:25:29 +01:00
config.json Removes CA Certificte and CRL signing from the default config 2015-03-14 12:42:14 +00:00
config.py Fixing several issues in Anchor startup 2015-03-05 11:47:58 +00:00
requirements.txt Bumpping cryptograpbhy version to match global requirements 2015-03-31 10:21:54 +01:00
run_tests.sh Adding run_tests.sh following OpenStack Standards 2015-02-17 12:29:04 -08:00
setup.cfg Clean up nits in setup.cfg 2015-03-27 12:11:49 -07:00
setup.py Bringing Anchor project setup inline with OpenStack 2015-01-08 14:20:38 +00:00
test-requirements-bandit.txt Adding Bandit gate test scaffolding 2015-04-17 09:25:29 +01:00
test-requirements.txt Adding tests for auth with Keystone Token 2015-02-20 11:36:01 -08:00
tox.ini Adding Bandit gate test scaffolding 2015-04-17 09:25:29 +01:00

README.md

Anchor

Anchor is an ephemeral PKI service that, based on certain conditions, automates the verification of CSRs and signs certificates for clients. The validity period can be set in the config file with hour resolution.

Installation

This service requires either a python virtual environment and python/ssl/ldap/sasl development system packages, or system python-ldap, python-pecan packages.

For virtual environment run:

virtualenv .venv
. .venv/bin/activate

To install a development version of Anchor, run:

python setup.py develop
pip install watchdog

Note that watchdog is needed only when running with the --reload option used later. To install a production version, run:

python setup.py install

The config file should be copied from config.py with any details updated.

Anchor requires you to provide a CA signing certificate and private key which is stored in the CA subdirectory by default (as specified in config.py). This can be generated using the certificate provider of your choice, or a test signing certificate can be generated using openssl:

Create a private key with password 'x', and then decrypt it:

cd CA
openssl genrsa -aes128 -passout pass:x -out ca.p.key 4096
openssl rsa -passin pass:x -in ca.p.key -out root-ca-unwrapped.key

Then create a CSR from that key, specify 'Test Anchor CA' or similar as the Common Name for the certificate:

openssl req -new -key root-ca-unwrapped.key -out ca.csr

Finally, sign the CSR to create a self-signed root certificate:

openssl x509 -req -days 365 -in ca.csr \
-signkey root-ca-unwrapped.key -out root-ca.crt
rm ca.p.key ca.csr

The service can be run during development with:

.venv/bin/pecan serve --reload config.py

In production, the package should be instead installed using:

pip install '.[production]'

And the debug option in config.py has to be turned off. Service can be started via the uwsgi server, for example (with 4 processes):

uwsgi --http-socket :5000 --venv /path/to/the/virtualenv \
--pecan /path/to/config.py -p 4

To test the service, generate the certificate request using default values and submit it using curl (change the user and secret if you have changed them in config.py):

openssl req -text -newkey rsa:4096 -nodes \
-out subdomain.example.org.csr

curl http://127.0.0.1:5000/sign -F user='woot' -F secret='woot' \
-F encoding=pem -F 'csr=<subdomain.example.org.csr'

Assuming the installation is successful and the default config is unchanged, this will fail validation, but should not give an OpenSSL or other error. This is assuming you set the CN to be subdomain.example.org, which is not permitted in the default config. Now generate a valid CSR that should pass validation and check that it is issued, by specifying a common name of 'anchor-test.example.com' when prompted:

openssl req -text -newkey rsa:4096 -nodes \
-out anchor-test.example.com.csr

curl http://127.0.0.1:5000/sign -F user='woot' -F secret='woot' \
-F encoding=pem -F 'csr=<anchor-test.example.com.csr'

If Anchor is correctly configured, the CA will return a certificate.