Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Opinionated letsencrypt acme client working via a ssh port forward.

Project Description


An opinionated script to sign tls keys via letsencrypt on your local computer by forwarding the HTTP/DNS challenge via ssh.


Best installed via pipsi:

% pipsi install certsling

Or some other way to install a python package with included scripts.


You need an openssl executable in your path for key generation and signing.

Testing with staging server

With the -s option you can use the staging server of letsencrypt. This is advised, so you don’t run into quota limits or similar until your setup works. The resulting certificate won’t validate, but otherwise has the same content as a regular certificate.

Basic usage

Create a directory with the email address as the name, which you want to use for authentication with letsencrypt. For example

% mkdir

Create a ssh connection to your server which forwards a remote port to the local port 8080:

% ssh -R 8080:localhost:8080

On your server the webserver needs to proxy requests to* to that forwarded port. An example for nginx:

location /.well-known/acme-challenge/ {
    proxy_pass http://localhost:8080;

From the directory you created earlier, invoke the certsling script with for example:

% cd
% certsling

On first run, you are asked whether to create a user.key for authorization with letsencrypt.

After that, challenges for the selected domains are created and a server is started on port 8080 to provide responses. Your remote web server proxies them through the ssh connection to the locally running server.

If all went well, you get a server key and certificate in a new folder:

% ls

The file contains the full chain of you certificate together with the letsencrypt certificate.

Advanced usage

To use DNS based authentication, you need to have socat on your server. Additionally you need to setup your DNS, so it delegates _acme-challenge requests to your server. For that you can add something similar to this to your zone file or equivalent:

_acme-challenge IN NS www
_acme-challenge.www IN NS www

For the forwarding, you need to add port 8053:: Create a ssh connection to your server which forwards a remote port to the local port 8080:

% ssh -R 8080:localhost:8080 -R 8053:localhost:8053

Then in that ssh session, run the following to forward UDP port 53 to TCP on port 8053:

# socat -T15 udp4-recvfrom:53,reuseaddr,fork tcp:localhost:8053

For certsling you need to add the –dns` option:

% certsling --dns

It will then first try the HTTP challenge and if that fails it will try the DNS challenge.


0.8.0 - 2017-01-04

  • Add new --update (-u) option to avoid having to remember the settings for each domain. [fschulze]
  • Ask to repeat csr and crt generation on failure. [solidgoldbomb]
  • Switch to dnspython after it merged with dnspython3. [fschulze]

0.7.0 - 2016-12-30

  • Renamed to certsling. [fschulze]
  • Use symmetric difference in verify_domains. This catches problems due to typos in domain names and some other cases. [solidgoldbomb]
  • Update list of issuer names checked in verify_crt. [solidgoldbomb (Stacey Sheldon)]
  • More detailed error reporting. [fschulze]
  • Ask to agree to terms of use of letsencrypt and allow updating the registration. [fschulze]

0.6.0 - 2016-05-09

  • Upgrade to new X3 authority. [fschulze]

0.5.0 - 2016-02-12

  • Allow selection of staging server with -s option. [fschulze]

0.4.1 - 2016-01-29

  • Fix issue that the -chained.crt file wasn’t updated. [fschulze]

0.4.0 - 2016-01-12

  • Initial release [fschulze]

Release History

This version
History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(13.8 kB) Copy SHA256 Hash SHA256
Wheel 2.7 Jan 4, 2017
(15.2 kB) Copy SHA256 Hash SHA256
Source None Jan 4, 2017

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Google Google Cloud Servers Fastly Fastly CDN StatusPage StatusPage Statuspage DigiCert DigiCert EV Certificate