Certbot

class dna.utils.Certbot(args=[])[source]

Various utilities to interface with certbot

Parameters

args (list[str]) – parameters to use with every call to certbot, such as custom DNS plugin configurations and installers

When used with DNA, the arguments will always be supplemented by -i nginx to force the nginx webserver.

get_certs()[source]

Get all renewable certificates on this machine.

Returns

a list of all the RenewableCert on this machine

cert_else_false(domain, force_exact=False, force_wildcard=False)[source]

Get a certificate matching domain if there is one, else False

By default, this will return an exact match if it exists. If one does not exist, then it will search for a wildcard one level above. If that doesn’t exist either, returns False.

Parameters
  • domain (str) – the domain to match

  • force_exact (bool) – forcibly search for an exact match certificate only (defaults to False)

  • force_wildcard (bool) – forcibly search for a wildcard certificate only (defaults to False)

Returns

the matching RenewableCert if there is one, otherwise False

attach_cert(cert, domain, logger=<built-in function print>)[source]

Install cert on domain

Parameters
  • cert (RenewableCert) – the certificate to install

  • domain (str) – the domain to install the certificate on

  • logger (func) – the function to stream output to

run_bot(domains=[], args=[], logger=<built-in function print>)[source]

Run a bot command on domains using args and the instance-wide args

Parameters
  • domains (list[str]) – the domain names to pass to certbot

  • args (list[str]) – any extra arguments to pass to certbot, such as a command

  • logger (func) – the function to stream output to