Package: certsign
A tinyACMEPython 2 & 3 client library with minimal dependencies. ACME is a
protocol for domain certificate verification and signing initiated byLet’s Encrypt.
This package is meant to be used as a library and also comes with command line scripts.InstallationYou can choose to either install it in your user’s home directory or in the system directories.This package depends on having the OpenSSL executable in the PATH.Using pipTo install it fromPyPIusingpipcall:pip install certsignYou can also install it from a code checkout using:pip install .Install to user home directoryWith pip you can use the--useroption to install it to your user’s home directory:pip install --user certsignIf you install to the user directory on Linux$HOME/.local/binshould be in your$PATH-variable. On Linux you can add the following to.profileor.bashrcin your home directory, if$HOME/.local/binis not already in you PATH.# set PATH so it includes user's private .local/bin if it existsif[-d"$HOME/.local/bin"];thenPATH="$HOME/.local/bin:$PATH"fiThe location for the scripts and the method to add it to the PATH is different for MacOS/OSX
and Windows.UsageAs a librarySigning a Certificate Signing Request (CSR)This is the primary usage of this library:fromcertsignimportclientaccount_key='acme_directory_account.key'csr_file='your_domain.csr'challenges_path='/path/served/by/your/http/server'account_email='you@example.com'signed_cert=client.sign_csr(account_key,csr_file,challenges_path,account_email=account_email)Creating a private key and a CSRfromcertsignimportcryptoprivkey_path='/tmp/privkey.pem'csr_path='/tmp/example.com.csr'privkey=crypto.create_private_key(bits=2048)withopen(privkey_path,'bw')asf:f.write(privkey)csr=crypto.create_csr(privkey_path,['example.com','www.example.com'],openssl_conf='/etc/ssl/openssl.cnf')withopen(csr_path,'bw')asf:f.write(csr)Command linecertsignFor signing a Certificate Signing Request (CSR):certsign --account-key /path/to/account/key --csr /path/to/domain.csr \
  --challenge-dir /path/served/by/your/http/server \
  --account-email you@example.comcertsign-toolCreate a private key:certsign-tool privkey --bits=4096 --out=/path/to/privkey.pemCreate a CSR:certsign-tool csr --privkey=/path/to/privkey.pem \
  --out=/path/to/example.com.csr example.com www.example.comView the CSR you just created:certsign-tool view /path/to/example.com.csrcertsign-serverA simple server to respond to ACME challenges:certsign-server --challenge-dir /path/served/by/your/http/server \
  --addr localhost \
  --port 8000 \
  --pidfile /tmp/certsign.pid &To kill the server when finished:if[-f/tmp/certsign.pid];thenpkill-F/tmp/certsign.pidfiDevelopmentIt is recommended that you create a Python 3 virtual environment usingpyvenv, and a Python 2
virtual environment usingvirtualenv.Go to the root of this project (where setup.py is located) and run the following commands:For Python 3:pyvenvvenv-certsign-py3andsourcevenv-certsign-py3/bin/activateto activate.For Python 2:virtualenvvenv-certsign-py2andsourcevenv-certsign-py2/bin/activateto activate.Set up a development environment using the following command (with literal square brackets):pip install -e .[dev]To run the test in your current environment:python setup.py testTo run the tests for several Python versions:toxRelease ProcessThe release proccess is based on the official documentation fordistributing packages.Create a~/.pypircfile to upload to The Python Package Index (PyPI):[distutils]
index-servers =
    pypi

[pypi]
username: somepypiuser
password: somepasswordCreate a bindary and a source release and usetwineto upload the packages. Also sign the
packages using agpgkey:python setup.py sdist bdist_wheel
twine upload -r pypi dist/*