Certbot Documentation Overview 1.11.0
Certbot Documentation Overview 1.11.0
Release 1.11.0.dev0
Certbot Project
1 Introduction 1
1.1 Contributing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 How to run the client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Understanding the client in more depth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 What is a Certificate? 3
2.1 Certificates and Lineages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 Get Certbot 5
3.1 About Certbot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.3 Alternate installation methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4 User Guide 11
4.1 Certbot Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2 Getting certificates (and choosing plugins) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.3 Managing certificates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.4 Where are my certificates? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.5 Pre and Post Validation Hooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.6 Changing the ACME Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.7 Lock Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.8 Configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.9 Log Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.10 Certbot command-line options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.11 Getting help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5 Developer Guide 41
5.1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.2 Code components and layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.3 Coding style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.4 Use [Link] instead of os . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.5 Mypy type annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.6 Submitting a pull request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.7 Asking for help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.8 Building the Certbot and DNS plugin snaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.9 Updating certbot-auto and letsencrypt-auto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.10 Updating the documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.11 Running the client with Docker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6 Packaging Guide 51
6.1 Releases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
i
6.2 Notes for package maintainers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7 Backwards Compatibility 53
8 Resources 55
9 API Documentation 57
9.1 certbot package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Index 125
ii
CHAPTER
ONE
INTRODUCTION
Certbot is part of EFF’s effort to encrypt the entire Internet. Secure communication over the Web relies on HTTPS,
which requires the use of a digital certificate that lets browsers verify the identity of web servers (e.g., is that really
[Link]?). Web servers obtain their certificates from trusted third parties called certificate authorities (CAs).
Certbot is an easy-to-use client that fetches a certificate from Let’s Encrypt—an open certificate authority launched by
the EFF, Mozilla, and others—and deploys it to a web server.
Anyone who has gone through the trouble of setting up a secure website knows what a hassle getting and maintaining
a certificate is. Certbot and Let’s Encrypt can automate away the pain and let you turn on and manage HTTPS with
simple commands. Using Certbot and Let’s Encrypt is free, so there’s no need to arrange payment.
How you use Certbot depends on the configuration of your web server. The best way to get started is to use our
interactive guide. It generates instructions based on your configuration settings. In most cases, you’ll need root or
administrator access to your web server to run Certbot.
Certbot is meant to be run directly on your web server, not on your personal computer. If you’re using a hosted service
and don’t have direct access to your web server, you might not be able to use Certbot. Check with your hosting
provider for documentation about uploading certificates or using certificates issued by Let’s Encrypt.
Certbot is a fully-featured, extensible client for the Let’s Encrypt CA (or any other CA that speaks the ACME protocol)
that can automate the tasks of obtaining certificates and configuring webservers to use them. This client runs on Unix-
based operating systems.
To see the changes made to Certbot between versions please refer to our changelog.
1.1 Contributing
If you’d like to contribute to this project please read Developer Guide.
This project is governed by EFF’s Public Projects Code of Conduct.
1
Certbot Documentation, Release 1.11.0.dev0
1.3.1 Links
Documentation: [Link]
Software project: [Link]
Notes for developers: [Link]
Main Website: [Link]
Let’s Encrypt Website: [Link]
Community: [Link]
ACME spec: RFC 8555
ACME working area in github (archived): [Link]
2 Chapter 1. Introduction
CHAPTER
TWO
WHAT IS A CERTIFICATE?
A public key or digital certificate (formerly called an SSL certificate) uses a public key and a private key to enable
secure communication between a client program (web browser, email client, etc.) and a server over an encrypted SSL
(secure socket layer) or TLS (transport layer security) connection. The certificate is used both to encrypt the initial
stage of communication (secure key exchange) and to identify the server. The certificate includes information about
the key, information about the server identity, and the digital signature of the certificate issuer. If the issuer is trusted
by the software that initiates the communication, and the signature is valid, then the key can be used to communicate
securely with the server identified by the certificate. Using a certificate is a good way to prevent “man-in-the-middle”
attacks, in which someone in between you and the server you think you are talking to is able to insert their own
(harmful) content.
You can use Certbot to easily obtain and configure a free certificate from Let’s Encrypt, a joint project of EFF, Mozilla,
and many other sponsors.
3
Certbot Documentation, Release 1.11.0.dev0
THREE
GET CERTBOT
Table of Contents
• About Certbot
• System Requirements
• Alternate installation methods
– Snap
– Running with Docker
– Operating System Packages
– Certbot-Auto
Note: Unless you have very specific requirements, we kindly suggest that you use the installation instructions for
your system found at [Link].
5
Certbot Documentation, Release 1.11.0.dev0
bind to port 80 (if you use the standalone plugin) and to read and modify webserver configurations (if you use the
apache or nginx plugins). If none of these apply to you, it is theoretically possible to run without root privileges,
but for most users who want to avoid running an ACME client as root, either letsencrypt-nosudo or simp_le are more
appropriate choices.
The Apache plugin currently requires an OS with augeas version 1.0; currently it supports modern OSes based on
Debian, Ubuntu, Fedora, SUSE, Gentoo and Darwin.
3.3.1 Snap
Most modern Linux distributions (basically any that use systemd) can install Certbot packaged as a snap. Snaps are
available for x86_64, ARMv7 and ARMv8 architectures. The Certbot snap provides an easy way to ensure you have
the latest version of Certbot with features like automated certificate renewal preconfigured.
You can find instructions for installing the Certbot snap at [Link] by selecting your server
software and then choosing “snapd” in the “System” dropdown menu. (You should select “snapd” regardless of your
operating system, as our instructions are the same across all systems.)
Running Certbot with the certonly command will obtain a certificate and place it in the directory /etc/
letsencrypt/live on your system. Because Certonly cannot install the certificate from within Docker, you
must install the certificate manually according to the procedure recommended by the provider of your webserver.
There are also Docker images for each of Certbot’s DNS plugins available at [Link] which
automate doing domain validation over DNS for popular providers. To use one, just replace certbot/certbot in
the command above with the name of the image you want to use. For example, to use Certbot’s plugin for Amazon
Route 53, you’d use certbot/dns-route53. You may also need to add flags to Certbot and/or mount additional
directories to provide access to your DNS API credentials as specified in the DNS plugin documentation.
For more information about the layout of the /etc/letsencrypt directory, see Where are my certificates?.
Warning: While the Certbot team tries to keep the Certbot packages offered by various operating systems working
in the most basic sense, due to distribution policies and/or the limited resources of distribution maintainers, Certbot
OS packages often have problems that other distribution mechanisms do not. The packages are often old resulting
in a lack of bug fixes and features and a worse TLS configuration than is generated by newer versions of Certbot.
They also may not configure certificate renewal for you or have all of Certbot’s plugins available. For reasons like
these, we recommend most users follow the instructions at [Link] and OS packages are
only documented here as an alternative.
Arch Linux
Debian
If you run Debian Buster or Debian testing/Sid, you can easily install certbot packages through commands like:
If you run Debian Stretch, we recommend you use the packages in Debian backports repository. First you’ll have to
follow the instructions at [Link] to enable the Stretch backports repo, if you have
not already done so. Then run:
In all of these cases, there also packages available to help Certbot integrate with Apache, nginx, or various DNS
services. If you are using Apache or nginx, we strongly recommend that you install the python-certbot-apache
or python-certbot-nginx package so that Certbot can fully automate HTTPS configuration for your server. A
full list of these packages can be found through a command like:
They can be installed by running the same installation command above but replacing certbot with the name of the
desired package.
Ubuntu
If you run Ubuntu, certbot can be installed using:
Fedora
FreeBSD
• Port: cd /usr/ports/security/py-certbot && make install clean
• Package: pkg install py27-certbot
Gentoo
The official Certbot client is available in Gentoo Portage. From the official Certbot plugins, three of them are also
available in Portage. They need to be installed separately if you require their functionality.
Note: The app-crypt/certbot-dns-nsone package has a different maintainer than the other packages and
can lag behind in version.
NetBSD
• Build from source: cd /usr/pkgsrc/security/py-certbot && make install clean
• Install pre-compiled package: pkg_add py27-certbot
OpenBSD
• Port: cd /usr/ports/security/letsencrypt/client && make install clean
• Package: pkg_add letsencrypt
Other Operating Systems
OS packaging is an ongoing effort. If you’d like to package Certbot for your distribution of choice please have a look
at the Packaging Guide.
3.3.4 Certbot-Auto
We used to have a shell script named certbot-auto to help people install Certbot on UNIX operating systems,
however, this script is no longer supported. If you want to uninstall certbot-auto, you can follow our instructions
here.
Disable and remove the swapfile once the virtual environment is constructed:
Warning: Please do not use python certbot/[Link] install, python pip install
certbot, or easy_install certbot. Please do not attempt the installation commands as superuser/root
and/or without virtual environment, e.g. sudo python certbot/[Link] install, sudo pip
install, sudo ./venv/bin/.... These modes of operation might corrupt your operating system and are
not supported by the Certbot team!
FOUR
USER GUIDE
Table of Contents
• Certbot Commands
• Getting certificates (and choosing plugins)
– Apache
– Webroot
– Nginx
– Standalone
– DNS Plugins
– Manual
– Combining plugins
– Third-party plugins
• Managing certificates
– Re-creating and Updating Existing Certificates
– Changing a Certificate’s Domains
– Using ECDSA keys
11
Certbot Documentation, Release 1.11.0.dev0
• Log Rotation
• Certbot command-line options
• Getting help
Under the hood, plugins use one of several ACME protocol challenges to prove you control a domain. The options are
http-01 (which uses port 80) and dns-01 (requiring configuration of a DNS server on port 53, though that’s often not
the same machine as your webserver). A few plugins support more than one challenge type, in which case you can
choose one with --preferred-challenges.
There are also many third-party-plugins available. Below we describe in more detail the circumstances in which each
plugin can be used, and how to use it.
4.2.1 Apache
The Apache plugin currently supports modern OSes based on Debian, Fedora, SUSE, Gentoo and Darwin. This
automates both obtaining and installing certificates on an Apache webserver. To specify this plugin on the command
line, simply include --apache.
4.2.2 Webroot
If you’re running a local webserver for which you have the ability to modify the content being served, and you’d
prefer not to stop the webserver during the certificate issuance process, you can use the webroot plugin to obtain
a certificate by including certonly and --webroot on the command line. In addition, you’ll need to specify
--webroot-path or -w with the top-level directory (“web root”) containing the files served by your webserver.
For example, --webroot-path /var/www/html or --webroot-path /usr/share/nginx/html are
two common webroot paths.
If you’re getting a certificate for many domains at once, the plugin needs to know where each domain’s files are served
from, which could potentially be a separate directory for each domain. When requesting a certificate for multiple
domains, each domain will use the most recently specified --webroot-path. So, for instance,
would obtain a single certificate for all of those names, using the /var/www/example webroot directory for the
first two, and /var/www/other for the second two.
The webroot plugin works by creating a temporary file for each of your requested domains in ${webroot-path}/
.well-known/acme-challenge. Then the Let’s Encrypt validation server makes HTTP requests to validate
that the DNS for each requested domain resolves to the server running certbot. An example request made to your web
server would look like:
Note that to use the webroot plugin, your server must be configured to serve files from hidden directories. If /.
well-known is treated specially by your webserver configuration, you might need to modify the configuration to
ensure that files inside /.well-known/acme-challenge are served by the webserver.
4.2.3 Nginx
The Nginx plugin should work for most configurations. We recommend backing up Nginx configurations before using
it (though you can also revert changes to configurations with certbot --nginx rollback). You can use it by
providing the --nginx flag on the commandline.
certbot --nginx
4.2.4 Standalone
Use standalone mode to obtain a certificate if you don’t want to use (or don’t currently have) existing server software.
The standalone plugin does not rely on any other server software running on the machine where you obtain the
certificate.
To obtain a certificate using a “standalone” webserver, you can use the standalone plugin by including certonly and
--standalone on the command line. This plugin needs to bind to port 80 in order to perform domain validation,
so you may need to stop your existing webserver.
It must still be possible for your machine to accept inbound connections from the Internet on the specified port using
each requested domain name.
By default, Certbot first attempts to bind to the port for all interfaces using IPv6 and then bind to that port using IPv4;
Certbot continues so long as at least one bind succeeds. On most Linux systems, IPv4 traffic will be routed to the
bound IPv6 port and the failure during the second bind is expected.
Use --<challenge-type>-address to explicitly tell Certbot which interface (and protocol) to bind.
4.2.6 Manual
If you’d like to obtain a certificate running certbot on a machine other than your target webserver or perform the
steps for domain validation yourself, you can use the manual plugin. While hidden from the UI, you can use the plugin
to obtain a certificate by specifying certonly and --manual on the command line. This requires you to copy and
paste commands into another terminal session, which may be on a different computer.
The manual plugin can use either the http or the dns challenge. You can use the --preferred-challenges
option to choose the challenge of your preference.
The http challenge will ask you to place a file with a specific name and specific content in the /.well-known/
acme-challenge/ directory directly in the top-level directory (“web root”) containing the files served by your
webserver. In essence it’s the same as the webroot plugin, but not automated.
When using the dns challenge, certbot will ask you to place a TXT DNS record with specific contents under the
domain name consisting of the hostname for which you want a certificate issued, prepended by _acme-challenge.
For example, for the domain [Link], a zone file entry would look like:
Additionally you can specify scripts to prepare for validation and perform the authentication procedure and/or clean
up after it by using the --manual-auth-hook and --manual-cleanup-hook flags. This is described in more
depth in the hooks section.
Or you could create a certificate using the manual plugin for authentication and the nginx plugin for installation. (Note
that this certificate cannot be renewed automatically.)
Certificate Name shows the name of the certificate. Pass this name using the --cert-name flag to specify a
particular certificate for the run, certonly, certificates, renew, and delete commands. Example:
certbot certonly --cert-name [Link]
If you prefer, you can specify the domains individually like this:
certbot --expand -d [Link] -d [Link] -d [Link]
Consider using --cert-name instead of --expand, as it gives more control over which certificate is modified and
it lets you remove domains as well as adding them.
--allow-subset-of-names tells Certbot to continue with certificate generation if only some of the specified
domain authorizations can be obtained. This may be useful if some domains specified in a certificate no longer point
at this system.
Whenever you obtain a new certificate in any of these ways, the new certificate exists alongside any previously obtained
certificates, whether or not the previous certificates have expired. The generation of a new certificate counts against
several rate limits that are intended to prevent abuse of the ACME protocol, as described here.
The same format can be used to expand the set of domains a certificate contains, or to replace that set entirely:
Warning: If you obtain certificates using ECDSA keys, you should be careful not to downgrade your Certbot
installation since ECDSA keys are not supported by older versions of Certbot. Downgrades like this are possible
if you switch from something like the snaps or certbot-auto to packages provided by your operating system which
often lag behind.
key-type = ecdsa
After this option is set, newly obtained certificates will use ECDSA keys. This includes certificates managed by
Certbot that previously used RSA keys.
If you want to change a single certificate to use ECDSA keys, you’ll need to issue a new Certbot command setting
--key-type ecdsa on the command line like
When obtaining both ECDSA and RSA certificates for the same domains with Certbot, we recommend using the
--cert-name option to give your certificates names so that you can easily identify them. For instance, you may
want to append “ecdsa” to the name of your ECDSA certificate by using a command like
You can also specify the reason for revoking your certificate by using the reason flag. Reasons include
unspecified which is the default, as well as keycompromise, affiliationchanged, superseded, and
cessationofoperation:
Additionally, if a certificate is a test certificate obtained via the --staging or --test-cert flag, that flag must
be passed to the revoke subcommand. Once a certificate is revoked (or for other certificate management tasks), all
of a certificate’s relevant files can be removed from the system with the delete subcommand:
Note: If you don’t use delete to remove the certificate completely, it will be renewed automatically at the next
renewal event.
Note: Revoking a certificate will have no effect on the rate limit imposed by the Let’s Encrypt server.
Note: Let’s Encrypt CA issues short-lived certificates (90 days). Make sure you renew the certificates at least once in
3 months.
See also:
Many of the certbot clients obtained through a distribution come with automatic renewal out of the box, such as Debian
and Ubuntu versions installed through apt, CentOS/RHEL 7 through EPEL, etc. See Automated Renewals for more
details.
As of version 0.10.0, Certbot supports a renew action to check all installed certificates for impending expiry and
attempt to renew them. The simplest form is simply
certbot renew
This command attempts to renew any previously-obtained certificates that expire in less than 30 days. The same plugin
and options that were used at the time the certificate was originally issued will be used for the renewal attempt, unless
you specify other plugins or options. Unlike certonly, renew acts on multiple certificates and always takes into
account whether each one is near expiry. Because of this, renew is suitable (and designed) for automated use, to
allow your system to automatically renew each certificate when appropriate. Since renew only renews certificates
that are near expiry it can be run as frequently as you want - since it will usually take no action.
The renew command includes hooks for running commands or scripts before or after a certificate is renewed. For
example, if you have a single certificate obtained using the standalone plugin, you might need to stop the webserver
before renewing so standalone can bind to the necessary ports, and then restart it after the plugin is finished. Example:
certbot renew --pre-hook "service nginx stop" --post-hook "service nginx start"
If a hook exits with a non-zero exit code, the error will be printed to stderr but renewal will be attempted anyway. A
failing hook doesn’t directly cause Certbot to exit with a non-zero exit code, but since Certbot exits with a non-zero exit
code when renewals fail, a failed hook causing renewal failures will indirectly result in a non-zero exit code. Hooks
will only be run if a certificate is due for renewal, so you can run the above command frequently without unnecessarily
stopping your webserver.
When Certbot detects that a certificate is due for renewal, --pre-hook and --post-hook hooks run before and
after each attempt to renew it. If you want your hook to run only after a successful renewal, use --deploy-hook in
a command like this.
certbot renew --deploy-hook /path/to/deploy-hook-script
You can also specify hooks by placing files in subdirectories of Certbot’s configuration directory. Assuming
your configuration directory is /etc/letsencrypt, any executable files found in /etc/letsencrypt/
renewal-hooks/pre, /etc/letsencrypt/renewal-hooks/deploy, and /etc/letsencrypt/
renewal-hooks/post will be run as pre, deploy, and post hooks respectively when any certificate is renewed
with the renew subcommand. These hooks are run in alphabetical order and are not run for other subcommands.
(The order the hooks are run is determined by the byte value of the characters in their filenames and is not dependent
on your locale.)
Hooks specified in the command line, configuration file, or renewal configuration files are run as usual after running
all hooks in these directories. One minor exception to this is if a hook specified elsewhere is simply the path to
an executable file in the hook directory of the same type (e.g. your pre-hook is the path to an executable in /etc/
letsencrypt/renewal-hooks/pre), the file is not run a second time. You can stop Certbot from automatically
running executables found in these directories by including --no-directory-hooks on the command line.
More information about hooks can be found by running certbot --help renew.
If you’re sure that this command executes successfully without human intervention, you can add the command to
crontab (since certificates are only renewed when they’re determined to be near expiry, the command can run on a
regular basis, like every week or every day). In that case, you are likely to want to use the -q or --quiet quiet flag
to silence all output except errors.
If you are manually renewing all of your certificates, the --force-renewal flag may be helpful; it causes the
expiration time of the certificate(s) to be ignored when considering renewal, and attempts to renew each and every
installed certificate regardless of its age. (This form is not appropriate to run daily because each certificate will be
renewed every day, which will quickly run into the certificate authority rate limit.)
Note that options provided to certbot renew will apply to every certificate for which renewal is attempted; for
example, certbot renew --rsa-key-size 4096 would try to replace every near-expiry certificate with an
equivalent certificate using a 4096-bit RSA public key. If a certificate is successfully renewed using specified options,
those options will be saved and used for future renewals of that certificate.
An alternative form that provides for more fine-grained control over the renewal process (while renewing specified
certificates one at a time), is certbot certonly with the complete set of subject domains of a specific certificate
specified via -d flags. You may also want to include the -n or --noninteractive flag to prevent blocking on
user input (which is useful when running the command from cron).
certbot certonly -n -d [Link] -d [Link]
All of the domains covered by the certificate must be specified in this case in order to renew and replace the old
certificate rather than obtaining a new one; don’t forget any www. domains! Specifying a subset of the domains
creates a new, separate certificate containing only those domains, rather than replacing the original certificate. When
run with a set of domains corresponding to an existing certificate, the certonly command attempts to renew that
specific certificate.
Please note that the CA will send notification emails to the address you provide if you do not renew certificates that
are about to expire.
Certbot is working hard to improve the renewal process, and we apologize for any inconvenience you encounter in
integrating these commands into your individual environment.
Note: certbot renew exit status will only be 1 if a renewal attempt failed. This means certbot renew exit
status will be 0 if no certificate needs to be updated. If you write a custom script and expect to run a command only
after a certificate was actually renewed you will need to use the --deploy-hook since the exit status will be 0 both
on successful renewal and when renewal is not necessary.
Warning: Modifying any files in /etc/letsencrypt can damage them so Certbot can no longer properly
manage its certificates, and we do not recommend doing so.
For most tasks, it is safest to limit yourself to pointing symlinks at the files there, or using --deploy-hook to copy
/ make new files based upon those files, if your operational situation requires it (for instance, combining certificates
and keys in different way, or having copies of things with different specific permissions that are demanded by other
programs).
If the contents of /etc/letsencrypt/archive/CERTNAME are moved to a new folder, first specify the new
folder’s name in the renewal configuration file, then run certbot update_symlinks to point the symlinks in
/etc/letsencrypt/live/CERTNAME to the new folder.
If you would like the live certificate files whose symlink location Certbot updates on each run to reside in a dif-
ferent location, first move them to that location, then specify the full path of each of the four files in the renewal
configuration file. Since the symlinks are relative links, you must follow this with an invocation of certbot
update_symlinks.
For example, say that a certificate’s renewal configuration file previously contained the following directives:
archive_dir = /etc/letsencrypt/archive/[Link]
cert = /etc/letsencrypt/live/[Link]/[Link]
privkey = /etc/letsencrypt/live/[Link]/[Link]
chain = /etc/letsencrypt/live/[Link]/[Link]
fullchain = /etc/letsencrypt/live/[Link]/[Link]
The following commands could be used to specify where these files are located:
mv /etc/letsencrypt/archive/[Link] /home/user/me/certbot/example_archive
sed -i 's,/etc/letsencrypt/archive/[Link],/home/user/me/certbot/example_archive,
˓→' /etc/letsencrypt/renewal/[Link]
mv /etc/letsencrypt/live/[Link]/*.pem /home/user/me/certbot/
sed -i 's,/etc/letsencrypt/live/[Link],/home/user/me/certbot,g' /etc/letsencrypt/
˓→renewal/[Link]
certbot update_symlinks
Note: /etc/letsencrypt/archive and /etc/letsencrypt/keys contain all previous keys and certifi-
cates, while /etc/letsencrypt/live symlinks to the latest versions.
Warning: This must be kept secret at all times! Never share it with anyone, including Certbot developers.
You cannot put it into a safe, however - your server still needs to access this file in order for SSL/TLS to
work.
Note: As of Certbot version 0.29.0, private keys for new certificate default to 0600. Any changes to the group
mode or group owner (gid) of this file will be preserved on renewals.
This is what Apache needs for SSLCertificateKeyFile, and Nginx for ssl_certificate_key.
[Link] All certificates, including server certificate (aka leaf certificate or end-entity certificate). The
server certificate is the first one in this file, followed by any intermediates.
This is what Apache >= 2.4.8 needs for SSLCertificateFile, and what Nginx needs for ssl_certificate.
[Link] and [Link] (less common) [Link] contains the server certificate by itself, and [Link]
contains the additional intermediate certificate or certificates that web browsers will need in order to validate the
server certificate. If you provide one of these files to your web server, you must provide both of them, or some
browsers will show “This Connection is Untrusted” errors for your site, some of the time.
Apache < 2.4.8 needs these for SSLCertificateFile. and SSLCertificateChainFile, respectively.
If you’re using OCSP stapling with Nginx >= 1.3.7, [Link] should be provided as the
ssl_trusted_certificate to validate OCSP responses.
Note: All files are PEM-encoded. If you need other format, such as DER or PFX, then you could convert using
openssl. You can automate that with --deploy-hook if you’re using automatic renewal.
This will run the [Link] script, attempt the validation, and then run the [Link] script. Addi-
tionally certbot will pass relevant environment variables to these scripts:
• CERTBOT_DOMAIN: The domain being authenticated
• CERTBOT_VALIDATION: The validation string
• CERTBOT_TOKEN: Resource name part of the HTTP-01 challenge (HTTP-01 only)
• CERTBOT_REMAINING_CHALLENGES: Number of challenges remaining after the current challenge
• CERTBOT_ALL_DOMAINS: A comma-separated list of all domains challenged for the current certificate
Additionally for cleanup:
• CERTBOT_AUTH_OUTPUT: Whatever the auth script wrote to stdout
Example usage for HTTP-01:
˓→[Link]
/path/to/http/[Link]
#!/bin/bash
echo $CERTBOT_VALIDATION > /var/www/htdocs/.well-known/acme-challenge/$CERTBOT_TOKEN
/path/to/http/[Link]
#!/bin/bash
rm -f /var/www/htdocs/.well-known/acme-challenge/$CERTBOT_TOKEN
Example usage for DNS-01 (Cloudflare API v4) (for example purposes only, do not use as-is)
/path/to/dns/[Link]
#!/bin/bash
-H "X-Auth-Email: $EMAIL" \
-H "X-Auth-Key: $API_KEY" \
-H "Content-Type: application/json" | python -c "import sys,json;print(json.
˓→load([Link])['result'][0]['id'])")
-H "X-Auth-Email: $EMAIL" \
-H "X-Auth-Key: $API_KEY" \
-H "Content-Type: application/json" \
--data '{"type":"TXT","name":"'"$CREATE_DOMAIN"'","content":"'"$CERTBOT_
˓→VALIDATION"'","ttl":120}' \
# Sleep to make sure the change has time to propagate over to DNS
sleep 25
/path/to/dns/[Link]
#!/bin/bash
if [ -f /tmp/CERTBOT_$CERTBOT_DOMAIN/ZONE_ID ]; then
ZONE_ID=$(cat /tmp/CERTBOT_$CERTBOT_DOMAIN/ZONE_ID)
rm -f /tmp/CERTBOT_$CERTBOT_DOMAIN/ZONE_ID
fi
if [ -f /tmp/CERTBOT_$CERTBOT_DOMAIN/RECORD_ID ]; then
RECORD_ID=$(cat /tmp/CERTBOT_$CERTBOT_DOMAIN/RECORD_ID)
rm -f /tmp/CERTBOT_$CERTBOT_DOMAIN/RECORD_ID
fi
-H "X-Auth-Email: $EMAIL" \
-H "X-Auth-Key: $API_KEY" \
-H "Content-Type: application/json"
fi
fi
Note that these lock files will only prevent other instances of Certbot from using those directories, not other pro-
cesses. If you’d like to run multiple instances of Certbot simultaneously you should specify different directories as the
--work-dir, --logs-dir, and --config-dir for each instance of Certbot that you would like to run.
will delete the oldest one to make room for new logs. The number of subsequent logs can be changed by passing the
desired number to the command line flag --max-log-backups.
Note: Some distributions, including Debian and Ubuntu, disable certbot’s internal log rotation in favor of a more
traditional logrotate script. If you are using a distribution’s packages and want to alter the log rotation, check /etc/
logrotate.d/ for a certbot rotation script.
-n Run non-interactively
--test-cert Obtain a test certificate from a staging server
--dry-run Test "renew" or "certonly" without saving any certificates to disk
manage certificates:
certificates Display information about certificates you have from Certbot
revoke Revoke a certificate (supply --cert-name or --cert-path)
delete Delete a certificate (supply --cert-name)
optional arguments:
-h, --help show this help message and exit
-c CONFIG_FILE, --config CONFIG_FILE
path to config file (default: /etc/letsencrypt/[Link]
and ~/.config/letsencrypt/[Link])
-v, --verbose This flag can be used multiple times to incrementally
increase the verbosity of output, e.g. -vvv. (default:
-2)
(continues on next page)
automation:
Flags for automating execution & other tweaks
security:
Security parameters & server settings
testing:
The following flags are meant for testing and integration purposes only.
--test-cert, --staging
Use the staging server to obtain or revoke test
(invalid) certificates; equivalent to --server
[Link]
(default: False)
--debug Show tracebacks in case of errors, and allow certbot-
auto execution on experimental platforms (default:
False)
--no-verify-ssl Disable verification of the ACME server's certificate.
(default: False)
--http-01-port HTTP01_PORT
Port used in the http-01 challenge. This only affects
the port Certbot listens on. A conforming ACME server
will still attempt to connect on port 80. (default:
80)
--http-01-address HTTP01_ADDRESS
The address the server listens to during http-01
challenge. (default: )
--https-port HTTPS_PORT
Port used to serve HTTPS. This affects which port
Nginx will listen on after a LE certificate is
installed. (default: 443)
--break-my-certs Be willing to replace or renew valid certificates with
invalid (testing/staging) certificates (default:
False)
paths:
Flags for changing execution paths & servers
--cert-path CERT_PATH
Path to where certificate is saved (with auth --csr),
installed from, or revoked. (default: None)
--key-path KEY_PATH Path to private key for certificate installation or
revocation (if account key is missing) (default: None)
--fullchain-path FULLCHAIN_PATH
Accompanying path to a full certificate chain
(certificate plus chain). (default: None)
--chain-path CHAIN_PATH
Accompanying path to a certificate chain. (default:
None)
--config-dir CONFIG_DIR
Configuration directory. (default: /etc/letsencrypt)
--work-dir WORK_DIR Working directory. (default: /var/lib/letsencrypt)
--logs-dir LOGS_DIR Logs directory. (default: /var/log/letsencrypt)
--server SERVER ACME Directory Resource URI. (default:
[Link]
(continues on next page)
manage:
Various subcommands and flags are available for managing your
certificates:
run:
Options for obtaining & installing certificates
certonly:
Options for modifying how a certificate is obtained
renew:
The 'renew' subcommand will attempt to renew all certificates (or more
precisely, certificate lineages) you have previously obtained if they are
close to expiry, and print a summary of the results. By default, 'renew'
will reuse the options used to create obtain or most recently successfully
renew each certificate lineage. You can try it with `--dry-run` first. For
more fine-grained control, you can renew individual lineages with the
`certonly` subcommand. Hooks are available to run commands before and
after renewal; see [Link] for
more information on these.
certificates:
List certificates managed by Certbot
delete:
Options for deleting a certificate
revoke:
Options for revocation of certificates
--reason {unspecified,keycompromise,affiliationchanged,superseded,
˓→ cessationofoperation}
Specify reason for revoking certificate. (default:
unspecified)
--delete-after-revoke
Delete certificates after revoking them, along with
all previous and later versions of those certificates.
(default: None)
--no-delete-after-revoke
Do not delete certificates after revoking them. This
option should be used with caution because the 'renew'
subcommand will attempt to renew undeleted revoked
certificates. (default: None)
register:
Options for account registration
--register-unsafely-without-email
Specifying this flag enables registering an account
with no email address. This is strongly discouraged,
because you will be unable to receive notice about
impending expiration or revocation of your
certificates or problems with your Certbot
installation that will lead to failure to renew.
(continues on next page)
update_account:
Options for account modification
unregister:
Options for account deactivation.
install:
Options for modifying how a certificate is deployed
rollback:
Options for rolling back server configuration changes
plugins:
Options for the "plugins" subcommand
update_symlinks:
Recreates certificate and key symlinks in /etc/letsencrypt/live, if you
changed them by hand or edited a renewal configuration file
enhance:
Helps to harden the TLS configuration by adding security enhancements to
already existing configuration.
plugins:
Plugin Selection: Certbot client supports an extensible plugins
architecture. See 'certbot plugins' for a list of all installed plugins
and their names. You can force a particular plugin by setting options
provided below. Running --help <plugin_name> will list flags specific to
that plugin.
--configurator CONFIGURATOR
Name of the plugin that is both an authenticator and
an installer. Should not be used together with
--authenticator or --installer. (default: Ask)
-a AUTHENTICATOR, --authenticator AUTHENTICATOR
Authenticator plugin name. (default: None)
-i INSTALLER, --installer INSTALLER
Installer plugin name (also used to find domains).
(continues on next page)
apache:
Apache Web Server plugin (Please note that the default values of the
Apache plugin options change depending on the operating system Certbot is
run on.)
--apache-enmod APACHE_ENMOD
Path to the Apache 'a2enmod' binary (default: None)
--apache-dismod APACHE_DISMOD
Path to the Apache 'a2dismod' binary (default: None)
--apache-le-vhost-ext APACHE_LE_VHOST_EXT
SSL vhost configuration extension (default: -le-
[Link])
--apache-server-root APACHE_SERVER_ROOT
Apache server root directory (default: /etc/apache2)
--apache-vhost-root APACHE_VHOST_ROOT
Apache server VirtualHost configuration root (default:
(continues on next page)
dns-cloudflare:
Obtain certificates using a DNS TXT record (if you are using Cloudflare
for DNS).
--dns-cloudflare-propagation-seconds DNS_CLOUDFLARE_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
record. (default: 10)
--dns-cloudflare-credentials DNS_CLOUDFLARE_CREDENTIALS
Cloudflare credentials INI file. (default: None)
dns-cloudxns:
Obtain certificates using a DNS TXT record (if you are using CloudXNS for
DNS).
--dns-cloudxns-propagation-seconds DNS_CLOUDXNS_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
record. (default: 30)
--dns-cloudxns-credentials DNS_CLOUDXNS_CREDENTIALS
CloudXNS credentials INI file. (default: None)
dns-digitalocean:
Obtain certs using a DNS TXT record (if you are using DigitalOcean for
DNS).
--dns-digitalocean-propagation-seconds DNS_DIGITALOCEAN_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
record. (default: 10)
--dns-digitalocean-credentials DNS_DIGITALOCEAN_CREDENTIALS
DigitalOcean credentials INI file. (default: None)
dns-dnsimple:
Obtain certificates using a DNS TXT record (if you are using DNSimple for
DNS).
--dns-dnsimple-propagation-seconds DNS_DNSIMPLE_PROPAGATION_SECONDS
(continues on next page)
dns-dnsmadeeasy:
Obtain certificates using a DNS TXT record (if you are using DNS Made Easy
for DNS).
--dns-dnsmadeeasy-propagation-seconds DNS_DNSMADEEASY_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
record. (default: 60)
--dns-dnsmadeeasy-credentials DNS_DNSMADEEASY_CREDENTIALS
DNS Made Easy credentials INI file. (default: None)
dns-gehirn:
Obtain certificates using a DNS TXT record (if you are using Gehirn
Infrastructure Service for DNS).
--dns-gehirn-propagation-seconds DNS_GEHIRN_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
record. (default: 30)
--dns-gehirn-credentials DNS_GEHIRN_CREDENTIALS
Gehirn Infrastructure Service credentials file.
(default: None)
dns-google:
Obtain certificates using a DNS TXT record (if you are using Google Cloud
DNS for DNS).
--dns-google-propagation-seconds DNS_GOOGLE_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
record. (default: 60)
--dns-google-credentials DNS_GOOGLE_CREDENTIALS
Path to Google Cloud DNS service account JSON file.
(See [Link]
OAuth2ServiceAccount#creatinganaccount forinformation
about creating a service account and
[Link]
control#permissions_and_roles for information about
therequired permissions.) (default: None)
dns-linode:
Obtain certs using a DNS TXT record (if you are using Linode for DNS).
--dns-linode-propagation-seconds DNS_LINODE_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
record. (default: 120)
--dns-linode-credentials DNS_LINODE_CREDENTIALS
Linode credentials INI file. (default: None)
dns-luadns:
(continues on next page)
--dns-luadns-propagation-seconds DNS_LUADNS_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
record. (default: 30)
--dns-luadns-credentials DNS_LUADNS_CREDENTIALS
LuaDNS credentials INI file. (default: None)
dns-nsone:
Obtain certificates using a DNS TXT record (if you are using NS1 for DNS).
--dns-nsone-propagation-seconds DNS_NSONE_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
record. (default: 30)
--dns-nsone-credentials DNS_NSONE_CREDENTIALS
NS1 credentials file. (default: None)
dns-ovh:
Obtain certificates using a DNS TXT record (if you are using OVH for DNS).
--dns-ovh-propagation-seconds DNS_OVH_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
record. (default: 30)
--dns-ovh-credentials DNS_OVH_CREDENTIALS
OVH credentials INI file. (default: None)
dns-rfc2136:
Obtain certificates using a DNS TXT record (if you are using BIND for
DNS).
--dns-rfc2136-propagation-seconds DNS_RFC2136_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
record. (default: 60)
--dns-rfc2136-credentials DNS_RFC2136_CREDENTIALS
RFC 2136 credentials INI file. (default: None)
dns-route53:
Obtain certificates using a DNS TXT record (if you are using AWS Route53
for DNS).
--dns-route53-propagation-seconds DNS_ROUTE53_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
record. (default: 10)
dns-sakuracloud:
Obtain certificates using a DNS TXT record (if you are using Sakura Cloud
for DNS).
--dns-sakuracloud-propagation-seconds DNS_SAKURACLOUD_PROPAGATION_SECONDS
The number of seconds to wait for DNS to propagate
before asking the ACME server to verify the DNS
(continues on next page)
manual:
Authenticate through manual configuration or custom shell scripts. When
using shell scripts, an authenticator script must be provided. The
environment variables available to this script depend on the type of
challenge. $CERTBOT_DOMAIN will always contain the domain being
authenticated. For HTTP-01 and DNS-01, $CERTBOT_VALIDATION is the
validation string, and $CERTBOT_TOKEN is the filename of the resource
requested when performing an HTTP-01 challenge. An additional cleanup
script can also be provided and can use the additional variable
$CERTBOT_AUTH_OUTPUT which contains the stdout output from the auth
script. For both authenticator and cleanup script, on HTTP-01 and DNS-01
challenges, $CERTBOT_REMAINING_CHALLENGES will be equal to the number of
challenges that remain after the current one, and $CERTBOT_ALL_DOMAINS
contains a comma-separated list of all domains that are challenged for the
current certificate.
--manual-auth-hook MANUAL_AUTH_HOOK
Path or command to execute for the authentication
script (default: None)
--manual-cleanup-hook MANUAL_CLEANUP_HOOK
Path or command to execute for the cleanup script
(default: None)
nginx:
Nginx Web Server plugin
--nginx-server-root NGINX_SERVER_ROOT
Nginx server root directory. (default: /etc/nginx or
/usr/local/etc/nginx)
--nginx-ctl NGINX_CTL
Path to the 'nginx' binary, used for 'configtest' and
retrieving nginx version number. (default: nginx)
--nginx-sleep-seconds NGINX_SLEEP_SECONDS
Number of seconds to wait for nginx configuration
changes to apply when reloading. (default: 1)
null:
Null Installer
standalone:
Spin up a temporary webserver
webroot:
Place files in webroot directory
FIVE
DEVELOPER GUIDE
Table of Contents
• Getting Started
– Running a local copy of the client
– Find issues to work on
– Testing
41
Certbot Documentation, Release 1.11.0.dev0
If you’re on macOS, we recommend you skip the rest of this section and instead run Certbot in Docker. You can
find instructions for how to do this here. If you’re running on Linux, you can run the following commands to install
dependencies and set up a virtual environment where you can run Certbot.
Install the OS system dependencies required to run Certbot.
Set up the Python virtual environment that will host your Certbot local instance.
cd certbot
python tools/[Link]
Note: You may need to repeat this when Certbot’s dependencies change or when a new plugin is introduced.
You can now run the copy of Certbot from git either by executing venv3/bin/certbot, or by activating the virtual
environment. You can do the latter by running:
source venv3/bin/activate
After running this command, certbot and development tools like ipdb, ipython, pytest, and tox are available
in the shell where you ran the command. These tools are installed in the virtual environment and are kept separate
from your global Python installation. This works by setting environment variables so the right executables are found
and Python can pull in the versions of various packages needed by Certbot. More information can be found in the
virtualenv docs.
5.1.3 Testing
You can test your code in several ways:
• running the automated unit tests,
• running the automated integration tests
• running an ad hoc manual integration test
Warning: The full test suite may attempt to modify your system’s Apache config if your user has sudo permis-
sions, so it should not be run on a production Apache server.
tox -e integration
Tests will be run using pytest. A test report and a code coverage report will be displayed at the end of the integration
tests execution.
run_acme_server
• Starts a local instance of Pebble and runs in the foreground printing its logs.
• Press CTRL+C to stop this instance.
• This instance is configured to validate challenges against certbot executed locally.
Note: Some options are available to tweak the local ACME server. You can execute run_acme_server --help
to see the inline help of the run_acme_server tool.
certbot_test [ARGS...]
• Execute certbot with the provided arguments and other arguments useful for testing purposes, such as: verbose
output, full tracebacks in case Certbot crashes, etc.
• Execution is preconfigured to interact with the Pebble CA started with run_acme_server.
• Any arguments can be passed as they would be to Certbot (eg. certbot_test certonly -d test.
[Link]).
Here is a typical workflow to verify that Certbot successfully issued a certificate using an HTTP-01 challenge on a
machine with Python 3:
python tools/[Link]
source venv3/bin/activate
run_acme_server &
certbot_test certonly --standalone -d [Link]
# To stop Pebble, launch `fg` to get back the background job, then press CTRL+C
Running tests in CI
Certbot uses Azure Pipelines to run continuous integration tests. If you are using our Azure setup, a branch whose
name starts with test- will run all tests on that branch.
5.2.1 Plugin-architecture
Certbot has a plugin architecture to facilitate support for different webservers, other TLS servers, and operating sys-
tems. The interfaces available for plugins to implement are defined in [Link] and plugins/[Link].
The main two plugin interfaces are IAuthenticator, which implements various ways of proving domain control
to a certificate authority, and IInstaller, which configures a server to use a certificate once it is issued. Some
plugins, like the built-in Apache and Nginx plugins, implement both interfaces and perform both tasks. Others, like
the built-in Standalone authenticator, implement just one interface.
There are also IDisplay plugins, which can change how prompts are displayed to a user.
5.2.2 Authenticators
Authenticators are plugins that prove control of a domain name by solving a challenge provided by the ACME server.
ACME currently defines several types of challenges: HTTP, TLS-ALPN, and DNS, represented by classes in acme.
challenges. An authenticator plugin should implement support for at least one challenge type.
An Authenticator indicates which challenges it supports by implementing get_chall_pref(domain) to return
a sorted list of challenge types in preference order.
An Authenticator must also implement perform(achalls), which “performs” a list of challenges by, for instance,
provisioning a file on an HTTP server, or setting a TXT record in DNS. Once all challenges have succeeded or failed,
Certbot will call the plugin’s cleanup(achalls) method to remove any files or DNS records that were needed
only during authentication.
5.2.3 Installer
Installers plugins exist to actually setup the certificate in a server, possibly tweak the security configuration to make it
more correct and secure (Fix some mixed content problems, turn on HSTS, redirect to HTTPS, etc). Installer plugins
tell the main client about their abilities to do the latter via the supported_enhancements() call. We currently
have two Installers in the tree, the ApacheConfigurator. and the NginxConfigurator. External projects
have made some progress toward support for IIS, Icecast and Plesk.
Installers and Authenticators will oftentimes be the same class/object (because for instance both tasks can be performed
by a webserver like nginx) though this is not always the case (the standalone plugin is an authenticator that listens on
port 80, but it cannot install certs; a postfix plugin would be an installer but not an authenticator).
Installers and Authenticators are kept separate because it should be possible to use the
StandaloneAuthenticator (it sets up its own Python server to perform challenges) with a program that
cannot solve challenges itself (Such as MTA installers).
Note: The Certbot team is not currently accepting any new DNS plugins because we want to rethink our approach to
the challenge and resolve some issues like #6464, #6503, and #6504 first.
In the meantime, you’re welcome to release it as a third-party plugin. See certbot-dns-ispconfig for one example of
that.
Certbot client supports dynamic discovery of plugins through the setuptools entry points using the certbot.
plugins group. This way you can, for example, create a custom implementation of IAuthenticator or
the IInstaller without having to merge it with the core upstream source code. An example is provided in
examples/plugins/ directory.
While developing, you can install your plugin into a Certbot development virtualenv like this:
. venv/bin/activate
pip install -e examples/plugins/
certbot_test plugins
Your plugin should show up in the output of the last command. If not, it was not installed properly.
Once you’ve finished your plugin and published it, you can have your users install it system-wide with pip
install. Note that this will only work for users who have Certbot installed from OS packages or via pip.
If everything worked, the last command should list your plugin in the list of plugins found by Certbot. Once your
snap is published to the snap store, it will be installable through the name of the snap on the snap store without
the --dangerous flag. If you are also using Certbot’s metadata interface, you can run sudo snap connect
your-snap-name:your-plug-name-for-metadata certbot:certbot-metadata to connect your
snap to it.
def foo(arg):
"""Short description.
:returns: Argument
:rtype: int
"""
return arg
Also note that OpenSSL, which we rely on, has type definitions for crypto but not SSL. We use both. Those imports
should look like this:
Note: We are currently only accepting changes to certbot-auto that fix regressions on platforms where certbot-auto is
the recommended installation method at [Link] If you are unsure if a change you want to
make qualifies, don’t hesitate to ask for help!
python letsencrypt-auto-source/[Link]
Running [Link] will update the letsencrypt-auto-source/letsencrypt-auto script. Note that the
certbot-auto and letsencrypt-auto scripts in the root directory of the repository will remain unchanged
after this script is run. Your changes will be propagated to these files during the next release of Certbot.
5.9.3 Opening a PR
When opening a PR, ensure that the following files are committed:
1. letsencrypt-auto-source/[Link] and
letsencrypt-auto-source/pieces/bootstrappers/*
2. letsencrypt-auto-source/letsencrypt-auto (generated by [Link])
It might also be a good idea to double check that no changes were inadvertently made to the certbot-auto or
letsencrypt-auto scripts in the root of the repository. These scripts will be updated by the core developers
during the next release.
This would generate the HTML documentation in _build/html in your current docs/ directory.
Note: Linux users can simply run pip install docker-compose to get Docker Compose after installing
Docker Engine and activating your shell as described in the Getting Started section.
Now you can develop on your host machine, but run Certbot and test your changes in Docker. When using
docker-compose make sure you are inside your clone of the Certbot repository. As an example, you can run
the following command to check for linting errors:
You can also leave a terminal open running a shell in the Docker container and modify Certbot code in another window.
The Certbot repo on your host machine is mounted inside of the container so any changes you make immediately take
effect. To do this, run:
Now running the check for linting errors described above is as easy as:
tox -e lint
SIX
PACKAGING GUIDE
6.1 Releases
We release packages and upload them to PyPI (wheels and source tarballs).
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
The following scripts are used in the process:
• [Link]
We use git tags to identify releases, using Semantic Versioning. For example: v0.11.1.
Our packages are cryptographically signed and their signature can be verified using the PGP key
A2CFB51FA275A7286234E7B24D17C995CD9775F2. This key can be found on major key servers and at
[Link]
51
Certbot Documentation, Release 1.11.0.dev0
SEVEN
BACKWARDS COMPATIBILITY
All Certbot components including acme, Certbot, and non-third party plugins follow Semantic Versioning both for its
Python API and for the application itself. This means that we will not change behavior in a backwards incompatible
way except in a new major version of the project.
Note: None of this applies to the behavior of Certbot distribution mechanisms such as our snaps or OS packages
whose behavior may change at any time. Semantic versioning only applies to the common Certbot components that
are installed by various distribution methods.
For Certbot as an application, the command line interface and non-interactive behavior can be considered stable with
two exceptions. The first is that no aspects of Certbot’s console or log output should be considered stable and it may
change at any time. The second is that Certbot’s behavior should only be considered stable with certain files but not
all. Files with which users should expect Certbot to maintain its current behavior with are:
• /etc/letsencrypt/live/<domain>/{cert,chain,fullchain,privkey}.pem where
<domain> is the name given to --cert-name. If --cert-name is not set by the user, it is the first domain
given to --domains.
• CLI configuration files
• Hook directories in /etc/letsencrypt/renewal-hooks
Certbot’s behavior with other files may change at any point.
Another area where Certbot should not be considered stable is its behavior when not run in non-interactive mode which
also may change at any point.
In general, if we’re making a change that we expect will break some users, we will bump the major version and will
have warned about it in a prior release when possible. For our Python API, we will issue warnings using Python’s
warning module. For application level changes, we will print and log warning messages.
53
Certbot Documentation, Release 1.11.0.dev0
EIGHT
RESOURCES
Documentation: [Link]
Software project: [Link]
Notes for developers: [Link]
Main Website: [Link]
Let’s Encrypt Website: [Link]
Community: [Link]
ACME spec: RFC 8555
ACME working area in github (archived): [Link]
55
Certbot Documentation, Release 1.11.0.dev0
56 Chapter 8. Resources
CHAPTER
NINE
API DOCUMENTATION
9.1.1 Subpackages
[Link] package
Compatibility layer to run certbot both on Linux and Windows.
This package contains all logic that needs to be implemented specifically for Linux and for Windows. Then the rest of
certbot code relies on this module to be platform agnostic.
Submodules
[Link] module
57
Certbot Documentation, Release 1.11.0.dev0
Parameters
• file_path (str) – The file path to open
• flags (int) – Flags to apply on file while opened
• mode (int) – POSIX mode to apply on file when opened, Python defaults will be applied
if None
Returns the file descriptor to the opened file
Return type int
Raise OSError([Link]) if the file already exists and os.O_CREAT & os.O_EXCL are
set, OSError([Link]) on Windows if the file already exists and is a directory, and
os.O_CREAT is set.
[Link](file_path, mode=511)
Rewrite of original [Link] function, that will ensure on Windows that given mode is correctly applied.
Parameters
• file_path (str) – The file path to open
• mode (int) – POSIX mode to apply on leaf directory when created, Python defaults will
be applied if None
[Link](file_path, mode=511)
Rewrite of original [Link] function, that will ensure on Windows that given mode is correctly applied.
Parameters
• file_path (str) – The file path to open
• mode (int) – POSIX mode to apply on directory when created, Python defaults will be
applied if None
[Link](src, dst)
Rename a file to a destination path and handles situations where the destination exists.
Parameters
• src (str) – The current file path.
• dst (str) – The new file path.
[Link](file_path)
Find the real path for the given path. This method resolves symlinks, including recursive symlinks, and is
protected against symlinks that creates an infinite loop.
Parameters file_path (str) – The path to resolve
Returns The real path for the given path
Return type str
[Link].is_executable(path)
Is path an executable file?
Parameters path (str) – path to test
Returns True if path is an executable file
Return type bool
[Link].has_world_permissions(path)
Check if everybody/world has any right (read/write/execute) on a file given its path.
[Link] module
This compat module handles various platform specific calls that do not fall into one particular category.
[Link].raise_for_non_administrative_windows_rights()
On Windows, raise if current shell does not have the administrative rights. Do nothing on Linux.
Raises [Link] – If the current shell does not have administrative rights on Windows.
[Link].readline_with_timeout(timeout, prompt)
Read user input to return the first line entered, or raise after specified timeout.
Parameters
• timeout (float) – The timeout in seconds given to the user.
• prompt (str) – The prompt message to display to the user.
Returns The first line entered by the user.
Return type str
[Link].get_default_folder(folder_type)
Return the relevant default folder for the current OS
Parameters folder_type (str) – The type of folder to retrieve (config, work or logs)
Returns The relevant default folder.
Return type str
[Link].underscores_for_unsupported_characters_in_path(path)
Replace unsupported characters in path for current OS by underscores. :param str path: the path to normalize
:return: the normalized path :rtype: str
[Link].execute_command(cmd_name, shell_cmd, env=None)
Run a command:
• on Linux command will be run by the standard shell selected with Popen(shell=True)
• on Windows command will be run in a Powershell shell
Parameters
• cmd_name (str) – the user facing name of the hook being run
• shell_cmd (str) – shell command to execute
• env (dict) – environ to pass into Popen
Returns tuple (str stderr, str stdout)
[Link] module
This compat modules is a wrapper of the core os module that forbids usage of specific operations (e.g. chown, chmod,
getuid) that would be harmful to the Windows file security model of Certbot. This module is intended to replace
standard os module throughout certbot projects (except acme).
This module has the same API as the os module in the Python standard library except for the functions defined below.
[Link](*unused_args, **unused_kwargs)
Method [Link]() is forbidden
[Link](*unused_args, **unused_kwargs)
Method [Link]() is forbidden
[Link](*unused_args, **unused_kwargs)
Method [Link]() is forbidden
[Link](*unused_args, **unused_kwargs)
Method [Link]() is forbidden
[Link](*unused_args, **unused_kwargs)
Method [Link]() is forbidden
[Link](*unused_args, **unused_kwargs)
Method [Link]() is forbidden
[Link](*unused_args, **unused_kwargs)
Method [Link]() is forbidden
[Link](*unused_args, **unused_kwargs)
Method [Link]() is forbidden
[Link](*unused_args, **unused_kwargs)
Method [Link]() is forbidden
[Link](*unused_args, **unused_kwargs)
Method [Link]() is forbidden
[Link](*unused_args, **unused_kwargs)
Method [Link]() is forbidden
[Link](filename)
Encode filename (an [Link], bytes, or str) to the filesystem encoding with ‘surrogateescape’ error handler,
return bytes unchanged. On Windows, use ‘strict’ error handler if the file system encoding is ‘mbcs’ (which is
the default encoding).
[Link](filename)
Decode filename (an [Link], bytes, or str) from the filesystem encoding with ‘surrogateescape’ error han-
dler, return str unchanged. On Windows, use ‘strict’ error handler if the file system encoding is ‘mbcs’ (which
is the default encoding).
[Link].get_exec_path(env=None)
Returns the sequence of directories that will be searched for the named executable (similar to a shell) when
launching a process.
env must be an environment variable dict or None. If env is None, [Link] will be used.
[Link](fd, *args, **kwargs)
[Link](cmd, mode=’r’, buffering=-1)
class [Link]
Bases: object
inode()
Return inode of the entry; cached per entry.
is_dir()
Return True if the entry is a directory; cached per entry.
is_file()
Return True if the entry is a file; cached per entry.
is_symlink()
Return True if the entry is a symbolic link; cached per entry.
name
the entry’s base filename, relative to scandir() “path” argument
path
the entry’s full path name; equivalent to [Link](scandir_path, [Link])
stat()
Return stat_result object for the entry; cached per entry.
[Link]()
Return True if the process returning status was dumped to a core file.
[Link]()
Return the process return code from status.
[Link]()
Return True if a particular process was continued from a job control stop.
Return True if the process returning status was continued from a job control stop.
[Link]()
Return True if the process returning status exited via the exit() system call.
[Link]()
Return True if the process returning status was terminated by a signal.
[Link]()
Return True if the process returning status was stopped.
[Link]()
Return the signal that stopped the process that provided the status value.
[Link]()
Return the signal that terminated the process that provided the status value.
[Link]()
Abort the interpreter immediately.
This function ‘dumps core’ or otherwise fails in the hardest way possible on the hosting operating system. This
function never returns.
[Link]()
Change the current working directory to the specified path.
path may always be specified as a string. On some platforms, path may also be specified as an open file
descriptor.
If this functionality is unavailable, using it raises an exception.
[Link]()
Change root directory to path.
[Link]()
Close a file descriptor.
[Link]()
Closes all file descriptors in [fd_low, fd_high), ignoring errors.
[Link]()
Return a string-valued system configuration variable.
[Link].copy_file_range()
Copy count bytes from one file descriptor to another.
src Source file descriptor.
dst Destination file descriptor.
count Number of bytes to copy.
offset_src Starting offset in src.
offset_dst Starting offset in dst.
If offset_src is None, then src is read from the current position; respectively for offset_dst.
[Link].cpu_count()
Return the number of CPUs in the system; return None if indeterminable.
This number is not equivalent to the number of CPUs the current process can use. The number of usable CPUs
can be obtained with len(os.sched_getaffinity(0))
[Link]()
Return the name of the controlling terminal for this process.
[Link].device_encoding()
Return a string describing the encoding of a terminal’s file descriptor.
The file descriptor must be attached to a terminal. If the device is not a terminal, return None.
[Link]()
Return a duplicate of a file descriptor.
[Link].dup2()
Duplicate file descriptor.
[Link]
alias of [Link]
[Link]()
Execute an executable path with arguments, replacing current process.
path Path of executable file.
argv Tuple or list of strings.
[Link]()
Execute an executable path with arguments, replacing current process.
path Path of executable file.
argv Tuple or list of strings.
env Dictionary of strings mapping to strings.
[Link]()
Change to the directory of the given file descriptor.
fd must be opened on a directory, not a file. Equivalent to [Link](fd).
[Link]()
Change the access permissions of the file given by file descriptor fd.
Equivalent to [Link](fd, mode).
[Link]()
Change the owner and group id of the file specified by file descriptor.
Equivalent to [Link](fd, uid, gid).
[Link]()
Force write of fd to disk without forcing update of metadata.
[Link]()
Fork a child process.
Return 0 to child process and PID of child to parent process.
[Link]()
Fork a new process with a new pseudo-terminal as controlling tty.
Returns a tuple of (pid, master_fd). Like fork(), return pid of 0 to the child process, and pid of child to the parent
process. To both, return fd of newly opened pseudo-terminal.
[Link]()
Return the configuration limit name for the file descriptor fd.
If there is no limit, return -1.
[Link]()
Return the file system path representation of the object.
If the object is str or bytes, then allow it to pass through as-is. If the object defines __fspath__(), then return the
result of that method. All other types raise a TypeError.
[Link]()
Perform an fstatvfs system call on the given fd.
Equivalent to statvfs(fd).
[Link]()
Force write of fd to disk.
[Link]()
Truncate a file, specified by file descriptor, to a specific length.
[Link].get_blocking()
Get the blocking mode of the file descriptor.
Return False if the O_NONBLOCK flag is set, True if the flag is cleared.
[Link].get_inheritable()
Get the close-on-exe flag of the specified file descriptor.
[Link].get_terminal_size()
Return the size of the terminal window as (columns, lines).
The optional argument fd (default standard output) specifies which file descriptor should be queried.
If the file descriptor is not connected to a terminal, an OSError is thrown.
This function will only be defined if an implementation is available for this system.
shutil.get_terminal_size is the high-level function which should normally be used, os.get_terminal_size is the
low-level implementation.
[Link]()
Return a unicode string representing the current working directory.
[Link]()
Return a bytes string representing the current working directory.
[Link]()
Return the current process’s effective group id.
[Link]()
Return the current process’s effective user id.
[Link]()
Return the current process’s group id.
[Link](user, group) → list of groups to which a user belongs
Returns a list of groups to which a user belongs.
user: username to lookup group: base group id of the user
[Link]()
Return list of supplemental group IDs for the process.
[Link]()
Return average recent system load information.
Return the number of processes in the system run queue averaged over the last 1, 5, and 15 minutes as a tuple
of three floats. Raises OSError if the load average was unobtainable.
[Link]()
Return the actual login name.
[Link]()
Call the system call getpgid(), and return the result.
[Link]()
Return the current process group id.
[Link]()
Return the current process id.
[Link]()
Return the parent’s process id.
If the parent process has already exited, Windows machines will still return its id; others systems will return the
id of the ‘init’ process (1).
[Link]()
Return program scheduling priority.
[Link]()
Obtain a series of random bytes.
[Link]()
Return a tuple of the current process’s real, effective, and saved group ids.
[Link]()
Return a tuple of the current process’s real, effective, and saved user ids.
[Link]()
Call the system call getsid(pid) and return the result.
[Link]()
Return the current process’s user id.
[Link]()
Return the value of extended attribute attribute on path.
path may be either a string, a path-like object, or an open file descriptor. If follow_symlinks is False, and the
last element of the path is a symbolic
link, getxattr will examine the symbolic link itself instead of the file the link points to.
[Link](username, gid) → None
Call the system initgroups() to initialize the group access list with all of the groups of which the specified
username is a member, plus the specified group id.
[Link]()
Return True if the fd is connected to a terminal.
Return True if the file descriptor is an open file descriptor connected to the slave end of a terminal.
[Link]()
Kill a process with a signal.
[Link]()
Kill a process group with a signal.
[Link]()
Change the owner and group id of path to the numeric uid and gid.
This function will not follow symbolic links. Equivalent to [Link](path, uid, gid, follow_symlinks=False).
[Link]()
Create a hard link to a file.
If either src_dir_fd or dst_dir_fd is not None, it should be a file descriptor open to a directory, and the re-
spective path string (src or dst) should be relative; the path will then be relative to that directory.
If follow_symlinks is False, and the last element of src is a symbolic link, link will create a link to the sym-
bolic link itself instead of the file the link points to.
src_dir_fd, dst_dir_fd, and follow_symlinks may not be implemented on your platform. If they are un-
available, using them will raise a NotImplementedError.
[Link]()
Return a list containing the names of the files in the directory.
path can be specified as either str, bytes, or a path-like object. If path is bytes, the filenames returned will
also be bytes; in all other circumstances the filenames returned will be str.
If path is None, uses the path=’.’. On some platforms, path may also be specified as an open file descriptor;
the file descriptor must refer to a directory. If this functionality is unavailable, using it raises NotIm-
plementedError.
The list is in arbitrary order. It does not include the special entries ‘.’ and ‘..’ even if they are present in the
directory.
[Link]()
Return a list of extended attributes on path.
path may be either None, a string, a path-like object, or an open file descriptor. if path is None, listxattr will
examine the current directory. If follow_symlinks is False, and the last element of the path is a symbolic
link, listxattr will examine the symbolic link itself instead of the file the link points to.
[Link]()
Apply, test or remove a POSIX lock on an open file descriptor.
fd An open file descriptor.
command One of F_LOCK, F_TLOCK, F_ULOCK or F_TEST.
length The number of bytes to lock, starting at the current position.
[Link]()
Set the position of a file descriptor. Return the new position.
Return the new cursor position in number of bytes relative to the beginning of the file.
[Link]()
Perform a stat system call on the given path, without following symbolic links.
Like stat(), but do not follow symbolic links. Equivalent to stat(path, follow_symlinks=False).
[Link]()
Extracts a device major number from a raw device number.
[Link]()
Composes a raw device number from the major and minor device numbers.
[Link].memfd_create()
[Link]()
Extracts a device minor number from a raw device number.
[Link]()
Create a “fifo” (a POSIX named pipe).
If dir_fd is not None, it should be a file descriptor open to a directory, and path should be relative; path
will then be relative to that directory.
dir_fd may not be implemented on your platform. If it is unavailable, using it will raise a NotImplemented-
Error.
[Link]()
Create a node in the file system.
Create a node in the file system (file, device special file or named pipe) at path. mode specifies both the
permissions to use and the type of node to be created, being combined (bitwise OR) with one of S_IFREG,
S_IFCHR, S_IFBLK, and S_IFIFO. If S_IFCHR or S_IFBLK is set on mode, device defines the newly created
device special file (probably using [Link]()). Otherwise device is ignored.
If dir_fd is not None, it should be a file descriptor open to a directory, and path should be relative; path
will then be relative to that directory.
dir_fd may not be implemented on your platform. If it is unavailable, using it will raise a NotImplemented-
Error.
[Link]()
Add increment to the priority of process and return the new priority.
[Link]()
Open a pseudo-terminal.
Return a tuple of (master_fd, slave_fd) containing open file descriptors for both the master and slave ends.
[Link]()
Return the configuration limit name for the file or directory path.
If there is no limit, return -1. On some platforms, path may also be specified as an open file descriptor.
If this functionality is unavailable, using it raises an exception.
[Link]()
Create a pipe.
Returns a tuple of two file descriptors: (read_fd, write_fd)
[Link].pipe2()
Create a pipe with flags set atomically.
Returns a tuple of two file descriptors: (read_fd, write_fd)
flags can be constructed by ORing together one or more of these values: O_NONBLOCK, O_CLOEXEC.
[Link].posix_fadvise()
Announce an intention to access data in a specific pattern.
Announce an intention to access data in a specific pattern, thus allowing the kernel to make optimizations.
The advice applies to the region of the file specified by fd starting at offset and continuing for length bytes.
advice is one of POSIX_FADV_NORMAL, POSIX_FADV_SEQUENTIAL, POSIX_FADV_RANDOM,
POSIX_FADV_NOREUSE, POSIX_FADV_WILLNEED, or POSIX_FADV_DONTNEED.
[Link].posix_fallocate()
Ensure a file has allocated at least a particular number of bytes on disk.
Ensure that the file specified by fd encompasses a range of bytes starting at offset bytes from the beginning and
continuing for length bytes.
[Link].posix_spawn()
Execute the program specified by path in a new process.
path Path of executable file.
argv Tuple or list of strings.
env Dictionary of strings mapping to strings.
file_actions A sequence of file action tuples.
[Link]()
Writes the contents of bytes-like objects to a file descriptor at a given offset.
Combines the functionality of writev() and pwrite(). All buffers must be a sequence of bytes-like objects.
Buffers are processed in array order. Entire contents of first buffer is written before proceeding to second, and
so on. The operating system may set a limit (sysconf() value SC_IOV_MAX) on the number of buffers that can
be used. This function writes the contents of each object to the file descriptor and returns the total number of
bytes written.
The flags argument contains a bitwise OR of zero or more of the following flags:
• RWF_DSYNC
• RWF_SYNC
Using non-zero flags requires Linux 4.7 or newer.
[Link]()
Read from a file descriptor. Returns a bytes object.
[Link]()
Return a string representing the path to which the symbolic link points.
If dir_fd is not None, it should be a file descriptor open to a directory, and path should be relative; path will then
be relative to that directory.
dir_fd may not be implemented on your platform. If it is unavailable, using it will raise a NotImplementedError.
[Link]()
Read from a file descriptor fd into an iterable of buffers.
The buffers should be mutable buffers accepting bytes. readv will transfer data into each buffer until it is full
and then move on to the next buffer in the sequence to hold the rest of the data.
readv returns the total number of bytes read, which may be less than the total capacity of all the buffers.
[Link].register_at_fork()
Register callables to be called when forking a new process.
before A callable to be called in the parent before the fork() syscall.
after_in_child A callable to be called in the child after fork().
after_in_parent A callable to be called in the parent after fork().
‘before’ callbacks are called in reverse order. ‘after_in_child’ and ‘after_in_parent’ callbacks are called in order.
[Link]()
Remove a file (same as unlink()).
If dir_fd is not None, it should be a file descriptor open to a directory, and path should be relative; path
will then be relative to that directory.
dir_fd may not be implemented on your platform. If it is unavailable, using it will raise a NotImplemented-
Error.
[Link]()
Remove extended attribute attribute on path.
path may be either a string, a path-like object, or an open file descriptor. If follow_symlinks is False, and the
last element of the path is a symbolic
link, removexattr will modify the symbolic link itself instead of the file the link points to.
[Link]()
Remove a directory.
If dir_fd is not None, it should be a file descriptor open to a directory, and path should be relative; path
will then be relative to that directory.
dir_fd may not be implemented on your platform. If it is unavailable, using it will raise a NotImplemented-
Error.
[Link]()
Return an iterator of DirEntry objects for given path.
path can be specified as either str, bytes, or a path-like object. If path is bytes, the names of yielded DirEntry
objects will also be bytes; in all other circumstances they will be str.
If path is None, uses the path=’.’.
[Link].sched_get_priority_max()
Get the maximum scheduling priority for policy.
[Link].sched_get_priority_min()
Get the minimum scheduling priority for policy.
[Link].sched_getaffinity()
Return the affinity of the process identified by pid (or the current process if zero).
The affinity is returned as a set of CPU identifiers.
[Link].sched_getparam()
Returns scheduling parameters for the process identified by pid.
If pid is 0, returns parameters for the calling process. Return value is an instance of sched_param.
[Link].sched_getscheduler()
Get the scheduling policy for the process identifiedy by pid.
Passing 0 for pid returns the scheduling policy for the calling process.
class [Link].sched_param
Bases: tuple
Current has only one field: sched_priority”);
sched_priority A scheduling parameter.
n_fields = 1
n_sequence_fields = 1
n_unnamed_fields = 0
sched_priority
the scheduling priority
[Link].sched_rr_get_interval()
Return the round-robin quantum for the process identified by pid, in seconds.
Value returned is a float.
[Link].sched_setaffinity()
Set the CPU affinity of the process identified by pid to mask.
mask should be an iterable of integers identifying CPUs.
[Link].sched_setparam()
Set scheduling parameters for the process identified by pid.
If pid is 0, sets parameters for the calling process. param should be an instance of sched_param.
[Link].sched_setscheduler()
Set the scheduling policy for the process identified by pid.
If pid is 0, the calling process is changed. param is an instance of sched_param.
[Link].sched_yield()
Voluntarily relinquish the CPU.
[Link](out, in, offset, count) → byteswritten
sendfile(out, in, offset, count[, headers][, trailers], flags=0) -> byteswritten
Copy count bytes from file descriptor in to file descriptor out.
[Link].set_blocking()
Set the blocking mode of the specified file descriptor.
Set the O_NONBLOCK flag if blocking is False, clear the O_NONBLOCK flag otherwise.
[Link].set_inheritable()
Set the inheritable flag of the specified file descriptor.
[Link]()
Set the current process’s effective group id.
[Link]()
Set the current process’s effective user id.
[Link]()
Set the current process’s group id.
[Link]()
Set the groups of the current process to list.
[Link]()
Call the system call setpgid(pid, pgrp).
[Link]()
Make the current process the leader of its process group.
[Link]()
Set program scheduling priority.
[Link]()
Set the current process’s real and effective group ids.
[Link]()
Set the current process’s real, effective, and saved group ids.
[Link]()
Set the current process’s real, effective, and saved user ids.
[Link]()
Set the current process’s real and effective user ids.
[Link]()
Call the system call setsid().
[Link]()
Set the current process’s user id.
[Link]()
Set extended attribute attribute on path to value.
path may be either a string, a path-like object, or an open file descriptor. If follow_symlinks is False, and the
last element of the path is a symbolic
link, setxattr will modify the symbolic link itself instead of the file the link points to.
class [Link].stat_result
Bases: tuple
stat_result: Result from stat, fstat, or lstat.
This object may be accessed either as a tuple of (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)
or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.
Posix/windows: If your platform supports st_blksize, st_blocks, st_rdev, or st_flags, they are available as at-
tributes only.
See [Link] for more information.
n_fields = 19
n_sequence_fields = 10
n_unnamed_fields = 3
st_atime
time of last access
st_atime_ns
time of last access in nanoseconds
st_blksize
blocksize for filesystem I/O
st_blocks
number of blocks allocated
st_ctime
time of last change
st_ctime_ns
time of last change in nanoseconds
st_dev
device
st_gid
group ID of owner
st_ino
inode
st_mode
protection bits
st_mtime
time of last modification
st_mtime_ns
time of last modification in nanoseconds
st_nlink
number of hard links
st_rdev
device type (if inode device)
st_size
total size, in bytes
st_uid
user ID of owner
[Link]()
Perform a statvfs system call on the given path.
path may always be specified as a string. On some platforms, path may also be specified as an open file
descriptor.
If this functionality is unavailable, using it raises an exception.
class [Link].statvfs_result
Bases: tuple
statvfs_result: Result from statvfs or fstatvfs.
This object may be accessed either as a tuple of (bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flag,
namemax),
or via the attributes f_bsize, f_frsize, f_blocks, f_bfree, and so on.
See [Link] for more information.
f_bavail
f_bfree
f_blocks
f_bsize
f_favail
f_ffree
f_files
f_flag
f_frsize
f_fsid
f_namemax
n_fields = 11
n_sequence_fields = 10
n_unnamed_fields = 0
[Link]()
Translate an error code to a message string.
[Link]()
Create a symbolic link pointing to src named dst.
target_is_directory is required on Windows if the target is to be interpreted as a directory. (On Win-
dows, symlink requires Windows 6.0 or greater, and raises a NotImplementedError otherwise.) tar-
get_is_directory is ignored on non-Windows platforms.
If dir_fd is not None, it should be a file descriptor open to a directory, and path should be relative; path
will then be relative to that directory.
dir_fd may not be implemented on your platform. If it is unavailable, using it will raise a NotImplemented-
Error.
[Link]()
Force write of everything to disk.
[Link]()
Return an integer-valued system configuration variable.
[Link]()
Execute the command in a subshell.
[Link]()
Return the process group associated with the terminal specified by fd.
[Link]()
Set the process group associated with the terminal specified by fd.
class [Link].terminal_size
Bases: tuple
A tuple of (columns, lines) for holding terminal window size
columns
width of the terminal window in characters
lines
height of the terminal window in characters
n_fields = 2
n_sequence_fields = 2
n_unnamed_fields = 0
[Link]()
Return a collection containing process timing information.
The object returned behaves like a named tuple with these fields: (utime, stime, cutime, cstime,
elapsed_time)
All fields are floating point numbers.
class [Link].times_result
Bases: tuple
times_result: Result from [Link]().
This object may be accessed either as a tuple of (user, system, children_user, children_system, elapsed),
or via the attributes user, system, children_user, children_system, and elapsed.
See [Link] for more information.
children_system
system time of children
children_user
user time of children
elapsed
elapsed time since an arbitrary point in the past
n_fields = 5
n_sequence_fields = 5
n_unnamed_fields = 0
system
system time
user
user time
[Link]()
Truncate a file, specified by path, to a specific length.
On some platforms, path may also be specified as an open file descriptor. If this functionality is unavail-
able, using it raises an exception.
[Link]()
Return the name of the terminal device connected to ‘fd’.
fd Integer file descriptor handle.
[Link]()
Return an object identifying the current operating system.
The object behaves like a named tuple with the following fields: (sysname, nodename, release, version, ma-
chine)
class [Link].uname_result
Bases: tuple
uname_result: Result from [Link]().
This object may be accessed either as a tuple of (sysname, nodename, release, version, machine),
or via the attributes sysname, nodename, release, version, and machine.
See [Link] for more information.
machine
hardware identifier
n_fields = 5
n_sequence_fields = 5
n_unnamed_fields = 0
nodename
name of machine on network (implementation-defined)
release
operating system release
sysname
operating system name
version
operating system version
[Link]()
Remove a file (same as remove()).
If dir_fd is not None, it should be a file descriptor open to a directory, and path should be relative; path
will then be relative to that directory.
dir_fd may not be implemented on your platform. If it is unavailable, using it will raise a NotImplemented-
Error.
[Link]()
Delete an environment variable.
[Link]()
Return a bytes object containing random bytes suitable for cryptographic use.
[Link]()
Set the access and modified time of path.
path may always be specified as a string. On some platforms, path may also be specified as an open file
descriptor.
If this functionality is unavailable, using it raises an exception.
If times is not None, it must be a tuple (atime, mtime); atime and mtime should be expressed as float sec-
onds since the epoch.
If ns is specified, it must be a tuple (atime_ns, mtime_ns); atime_ns and mtime_ns should be expressed as
integer nanoseconds since the epoch.
If times is None and ns is unspecified, utime uses the current time. Specifying tuples for both times and ns is an
error.
If dir_fd is not None, it should be a file descriptor open to a directory, and path should be relative; path
will then be relative to that directory.
If follow_symlinks is False, and the last element of the path is a symbolic link, utime will modify the sym-
bolic link itself instead of the file the link points to.
It is an error to use dir_fd or follow_symlinks when specifying path as an open file descriptor.
dir_fd and follow_symlinks may not be available on your platform. If they are unavailable, using them will
raise a NotImplementedError.
[Link]()
Wait for completion of a child process.
Returns a tuple of information about the child process: (pid, status)
[Link].wait3()
Wait for completion of a child process.
Returns a tuple of information about the child process: (pid, status, rusage)
[Link].wait4()
Wait for completion of a specific child process.
Returns a tuple of information about the child process: (pid, status, rusage)
[Link]()
Returns the result of waiting for a process or processes.
idtype Must be one of be P_PID, P_PGID or P_ALL.
id The id to wait on.
options Constructed from the ORing of one or more of WEXITED, WSTOPPED or WCONTIN-
UED and additionally may be ORed with WNOHANG or WNOWAIT.
Returns either waitid_result or None if WNOHANG is specified and there are no children in a waitable state.
class [Link].waitid_result
Bases: tuple
waitid_result: Result from waitid.
This object may be accessed either as a tuple of (si_pid, si_uid, si_signo, si_status, si_code),
or via the attributes si_pid, si_uid, and so on.
See [Link] for more information.
n_fields = 5
n_sequence_fields = 5
n_unnamed_fields = 0
si_code
si_pid
si_signo
si_status
si_uid
[Link]()
Wait for completion of a given child process.
Returns a tuple of information regarding the child process: (pid, status)
The options argument is ignored on Windows.
[Link]()
Write a bytes object to a file descriptor.
[Link]()
Iterate over buffers, and write the contents of each to a file descriptor.
Returns the total number of bytes written. buffers must be a sequence of bytes-like objects.
[Link](name)
Super-rmdir; remove a leaf directory and all empty intermediate ones. Works like rmdir except that, if the leaf
directory is successfully removed, directories corresponding to rightmost path segments will be pruned away
until either the whole path is consumed or an error occurs. Errors during this latter phase are ignored – they
generally mean that a directory was not empty.
[Link](old, new)
Super-rename; create directories as necessary and delete any left empty. Works like rename, except creation
of any intermediate directories needed to make the new pathname good is attempted first. After the rename,
directories corresponding to rightmost path segments of the old name will be pruned until either the whole path
is consumed or a nonempty directory is found.
Note: this function can fail with the new directory structure made if you lack permissions needed to unlink the
leaf directory or file.
[Link](top, topdown=True, onerror=None, followlinks=False)
Directory tree generator.
For each directory in the directory tree rooted at top (including top itself, but excluding ‘.’ and ‘..’), yields a
3-tuple
dirpath, dirnames, filenames
dirpath is a string, the path to the directory. dirnames is a list of the names of the subdirectories in dirpath
(excluding ‘.’ and ‘..’). filenames is a list of the names of the non-directory files in dirpath. Note that the names
in the lists are just names, with no path components. To get a full path (which begins with top) to a file or
directory in dirpath, do [Link](dirpath, name).
If optional arg ‘topdown’ is true or not specified, the triple for a directory is generated before the triples for
any of its subdirectories (directories are generated top down). If topdown is false, the triple for a directory is
generated after the triples for all of its subdirectories (directories are generated bottom up).
When topdown is true, the caller can modify the dirnames list in-place (e.g., via del or slice assignment), and
walk will only recurse into the subdirectories whose names remain in dirnames; this can be used to prune the
search, or to impose a specific order of visiting. Modifying dirnames when topdown is false has no effect on
the behavior of [Link](), since the directories in dirnames have already been generated by the time dirnames
itself is generated. No matter the value of topdown, the list of subdirectories is retrieved before the tuples for
the directory and its subdirectories are generated.
By default errors from the [Link]() call are ignored. If optional arg ‘onerror’ is specified, it should be a
function; it will be called with one argument, an OSError instance. It can report the error to continue with the
walk, or raise the exception to abort the walk. Note that the filename is available as the filename attribute of the
exception object.
By default, [Link] does not follow symbolic links to subdirectories on systems that support them. In order to
get this functionality, set the optional argument ‘followlinks’ to true.
Caution: if you pass a relative pathname for top, don’t change the current working directory between resump-
tions of walk. walk never changes the current directory, and assumes that the client doesn’t either.
Example:
import os from [Link] import join, getsize for root, dirs, files in [Link](‘python/Lib/email’):
print(root, “consumes”, end=””) print(sum(getsize(join(root, name)) for name in files), end=””)
print(“bytes in”, len(files), “non-directory files”) if ‘CVS’ in dirs:
[Link](‘CVS’) # don’t visit CVS directories
[Link](top=’.’, topdown=True, onerror=None, *, follow_symlinks=False,
dir_fd=None)
Directory tree generator.
This behaves exactly like walk(), except that it yields a 4-tuple
dirpath, dirnames, filenames, dirfd
dirpath, dirnames and filenames are identical to walk() output, and dirfd is a file descriptor referring
to the directory dirpath.
The advantage of fwalk() over walk() is that it’s safe against symlink races (when follow_symlinks is False).
If dir_fd is not None, it should be a file descriptor open to a directory, and top should be relative; top will
then be relative to that directory. (dir_fd is always supported for fwalk.)
Caution: Since fwalk() yields file descriptors, those are only valid until the next iteration step, so you should
dup() them if you want to keep them for a longer period.
Example:
import os for root, dirs, files, rootfd in [Link](‘python/Lib/email’):
print(root, “consumes”, end=””) print(sum([Link](name, dir_fd=rootfd).st_size for name in files),
end=””)
print(“bytes in”, len(files), “non-directory files”) if ‘CVS’ in dirs:
[Link](‘CVS’) # don’t visit CVS directories
[Link](file, *args)
Execute the executable file with argument list args, replacing the current process.
environment. If mode == P_NOWAIT return the pid of the process. If mode == P_WAIT return the process’s
exit code if it exits normally; otherwise return -SIG, where SIG is the signal that killed it.
[Link](mode, file, *args, env) → integer
Execute file (which is looked for along $PATH) with arguments from args in a subprocess with the supplied
environment. If mode == P_NOWAIT return the pid of the process. If mode == P_WAIT return the process’s
exit code if it exits normally; otherwise return -SIG, where SIG is the signal that killed it.
[Link] package
Certbot display utilities.
Submodules
[Link] module
[Link].success_installation(domains)
Display a box confirming the installation of HTTPS.
Parameters domains (list) – domain names which were enabled
[Link].success_renewal(domains)
Display a box confirming the renewal of an existing certificate.
Parameters domains (list) – domain names which were renewed
[Link].success_revocation(cert_path)
Display a message confirming a certificate has been revoked.
Parameters cert_path (list) – path to certificate which was revoked.
[Link].validated_input(validator, *args, **kwargs)
Like input, but with validation.
Parameters
• validator (callable) – A method which will be called on the supplied input. If
the method raises an [Link], its text will be displayed and the user will be re-
prompted.
• *args (list) – Arguments to be passed to input.
• **kwargs (dict) – Arguments to be passed to input.
Returns as input
Return type tuple
[Link].validated_directory(validator, *args, **kwargs)
Like directory_select, but with validation.
Parameters
• validator (callable) – A method which will be called on the supplied input. If
the method raises an [Link], its text will be displayed and the user will be re-
prompted.
• *args (list) – Arguments to be passed to directory_select.
• **kwargs (dict) – Arguments to be passed to directory_select.
Returns as directory_select
Return type tuple
[Link] module
Certbot display.
This module ([Link]) or its companion [Link] should be used whenever:
• Displaying status information to the user on the terminal
• Collecting information from the user via prompts
Other messages can use the logging module. See [Link].
[Link] = 'ok'
Display exit code indicating user acceptance.
[Link] = 'cancel'
Display exit code for a user canceling the display.
[Link] = 'help'
Display exit code when for when the user requests more help. (UNUSED)
[Link] = 'esc'
Display exit code when the user hits Escape (UNUSED)
[Link].SIDE_FRAME = '- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Display boundary (alternates spaces, so when copy-pasted, markdown doesn’t interpret it as a heading)
[Link].input_with_timeout(prompt=None, timeout=36000.0)
Get user input with a timeout.
Behaves the same as [Link], however, an error is raised if a user doesn’t answer after timeout seconds.
The default timeout value was chosen to place it just under 12 hours for users following our advice and running
Certbot twice a day.
Parameters
• prompt (str) – prompt to provide for input
• timeout (float) – maximum number of seconds to wait for input
Returns user response
Return type str
:raises [Link] if no answer is given before the timeout
[Link](msg)
Display a basic status message.
Parameters msg (str) – message to display
class [Link](outfile, force_interactive)
Bases: object
File-based display.
notification(message, pause=True, wrap=True, force_interactive=False, decorate=True)
Displays a notification and waits for user acceptance.
Parameters
• message (str) – Message to display
• pause (bool) – Whether or not the program should pause for the user’s confirmation
• wrap (bool) – Whether or not the application should wrap text
• force_interactive (bool) – True if it’s safe to prompt the user because it won’t
cause any workflow regressions
• decorate (bool) – Whether to surround the message with a decorated frame
menu(message, choices, ok_label=None, cancel_label=None, help_label=None, default=None,
cli_flag=None, force_interactive=False, **unused_kwargs)
Display a menu.
Parameters
• message (str) – title of menu
• cli_flag (str) – option used to set this value with the CLI
• force_interactive (bool) – True if it’s safe to prompt the user because it won’t
cause any workflow regressions
Returns tuple of (code, tags) where code - str display exit code tags - list of selected tags
Return type tuple
directory_select(message, default=None, cli_flag=None, force_interactive=False, **un-
used_kwargs)
Display a directory selection screen.
Parameters
• message (str) – prompt to give the user
• default – default value to return (if one exists)
• cli_flag (str) – option used to set this value with the CLI
• force_interactive (bool) – True if it’s safe to prompt the user because it won’t
cause any workflow regressions
Returns tuple of the form (code, string) where code - display exit code string - input
entered by the user
[Link].assert_valid_call(prompt, default, cli_flag, force_interactive)
Verify that provided arguments is a valid IDisplay call.
Parameters
• prompt (str) – prompt for the user
• default – default answer to prompt
• cli_flag (str) – command line option for setting an answer to this question
• force_interactive (bool) – if interactivity is forced by the IDisplay call
class [Link](outfile, *unused_args, **un-
used_kwargs)
Bases: object
An iDisplay implementation that never asks for interactive user input
notification(message, pause=False, wrap=True, decorate=True, **unused_kwargs)
Displays a notification without waiting for user acceptance.
Parameters
• message (str) – Message to display to stdout
• pause (bool) – The NoninteractiveDisplay waits for no keyboard
• wrap (bool) – Whether or not the application should wrap text
• decorate (bool) – Whether to apply a decorated frame to the message
menu(message, choices, ok_label=None, cancel_label=None, help_label=None, default=None,
cli_flag=None, **unused_kwargs)
Avoid displaying a menu.
Parameters
• message (str) – title of menu
Returns tuple of the form (code, string) where code - int display exit code string - input
entered by the user
[Link].separate_list_input(input_)
Separate a comma or space separated list.
Parameters input (str) – input from the user
Returns strings
Return type list
[Link].summarize_domain_list(domains)
Summarizes a list of domains in the format of: [Link] and N more domains
or if there is are only two domains: [Link] and [Link]
or if there is only one domain: [Link]
[Link] package
Certbot plugins.
Submodules
[Link] module
dest_namespace
ArgumentParser dest namespace (prefix of all destinations).
dest(var)
Find a destination for given variable var.
conf(var)
Find a configuration value for variable var.
class [Link](*args, **kwargs)
Bases: [Link]
An installer base class with reverter and ssl_dhparam methods defined.
Installer plugins do not have to inherit from this class.
add_to_checkpoint(save_files, save_notes, temporary=False)
Add files to a checkpoint.
Parameters
• save_files (set) – set of filepaths to save
• save_notes (str) – notes about changes during the save
• temporary (bool) – True if the files should be added to a temporary checkpoint rather
than a permanent one. This is usually used for changes that will soon be reverted.
Raises [Link] – when unable to add to checkpoint
finalize_checkpoint(title)
Timestamp and save changes made through the reverter.
Parameters title (str) – Title describing checkpoint
Raises [Link] – when an error occurs
recovery_routine()
Revert all previously modified files.
Reverts all modified files that have not been saved as a checkpoint
Raises [Link] – If unable to recover the configuration
revert_temporary_config()
Rollback temporary checkpoint.
Raises [Link] – when unable to revert config
rollback_checkpoints(rollback=1)
Rollback saved checkpoints.
Parameters rollback (int) – Number of checkpoints to revert
Raises [Link] – If there is a problem with the input or the function is unable
to correctly revert the configuration
ssl_dhparams
Full absolute path to ssl_dhparams file.
updated_ssl_dhparams_digest
Full absolute path to digest of updated ssl_dhparams file.
install_ssl_dhparams()
Copy Certbot’s ssl_dhparams file into the system’s config dir if required.
[Link].dns_common module
[Link].dns_common.base_domain_name_guesses(domain)
Return a list of progressively less-specific domain names.
One of these will probably be the domain name known to the DNS provider.
Example
>>> base_domain_name_guesses('[Link]')
['[Link]', '[Link]', '[Link]', '[Link]
˓→', 'com']
[Link].dns_common_lexicon module
[Link].dns_test_common module
[Link].dns_test_common_lexicon module
test_add_txt_record_fail_to_authenticate_with_unknown_error()
test_add_txt_record_error_finding_domain()
test_add_txt_record_error_adding_record()
test_del_txt_record()
test_del_txt_record_fail_to_find_domain()
test_del_txt_record_fail_to_authenticate()
test_del_txt_record_fail_to_authenticate_with_unknown_error()
test_del_txt_record_error_finding_domain()
test_del_txt_record_error_deleting_record()
[Link] module
class [Link]
Bases: object
Enhancement interface that installer plugins can implement in order to provide functionality that configures the
software to have a ‘Strict-Transport-Security’ with initially low max-age value that will increase over time.
The plugins implementing new style enhancements are responsible of handling the saving of configuration
checkpoints as well as calling possible restarts of managed software themselves. For update_autohsts method,
the installer may have to call prepare() to finalize the plugin initialization.
Methods: enable_autohsts is called when the header is initially installed using a low max-age value.
update_autohsts is called every time when Certbot is run using ‘renew’ verb. The max-age value should
be increased over time using this method.
deploy_autohsts is called for every lineage that has had its certificate renewed. A long HSTS max-age
value should be set here, as we should be confident that the user is able to automatically renew their
certificates.
update_autohsts(lineage, *args, **kwargs)
Gets called for each lineage every time Certbot is run with ‘renew’ verb. Implementation of this method
should increase the max-age value.
Parameters lineage ([Link]) – Certificate lineage
object
Note: prepare() method inherited from [Link] might need to be called manually
within implementation of this interface method to finalize the plugin initialization.
[Link] module
put(key, value)
Put configuration value to PluginStorage
Parameters
• key (str) – Key to store the value to
• value – Data to store
fetch(key)
Get configuration value from PluginStorage
Parameters key (str) – Key to get value from the storage
Raises KeyError – If the key doesn’t exist in the storage
[Link] module
Plugin utilities.
[Link].get_prefixes(path)
Retrieves all possible path prefixes of a path, in descending order of length. For instance,
(linux) /a/b/c returns [‘/a/b/c’, ‘/a/b’, ‘/a’, ‘/’] (windows) C:abc returns [‘C:abc’, ‘C:ab’, ‘C:a’, ‘C:’]
[Link].path_surgery(cmd)
Attempt to perform PATH surgery to find cmd
Mitigates [Link]
Parameters cmd (str) – the command that is being searched for in the PATH
Returns True if the operation succeeded, False otherwise
[Link] package
Utilities for running Certbot tests
Submodules
[Link].acme_util module
[Link] module
Test utilities.
[Link].vector_path(*names)
Path to a test vector.
[Link].load_vector(*names)
Load contents of a test vector.
[Link].load_cert(*names)
Load certificate.
[Link].load_csr(*names)
Load certificate request.
[Link].load_comparable_csr(*names)
Load ComparableX509 certificate request.
[Link].load_rsa_private_key(*names)
Load RSA private key.
[Link].load_pyopenssl_private_key(*names)
Load pyOpenSSL private key.
[Link].make_lineage(config_dir, testfile, ec=False)
Creates a lineage defined by testfile.
This creates the archive, live, and renewal directories if necessary and creates a simple lineage.
Parameters
• config_dir (str) – path to the configuration directory
• testfile (str) – configuration file to base the lineage on
Returns path to the renewal conf file for the created lineage
Return type str
[Link].patch_get_utility(target=’[Link]’)
Patch [Link] to use a special mock IDisplay.
The mock IDisplay works like a regular mock object, except it also also asserts that methods are called with
valid arguments.
Parameters target (str) – path to patch
Returns mock [Link]
Return type [Link]
[Link].patch_get_utility_with_stdout(target=’[Link]’,
stdout=None)
Patch [Link] to use a special mock IDisplay.
The mock IDisplay works like a regular mock object, except it also also asserts that methods are called with
valid arguments.
The message argument passed to the IDisplay methods is passed to stdout’s write method.
Parameters
9.1.2 Submodules
[Link] module
Client annotated ACME challenges.
Please use names such as achall to distinguish from variables “of type” [Link] (de-
noted by chall) and ChallengeBody (denoted by challb):
chall = [Link](token='foo')
challb = [Link](chall=chall)
achall = [Link](chall=challb, domain='[Link]')
[Link] == [Link]
class [Link](**kwargs)
Bases: [Link]
Client annotated challenge.
Wraps around server provided challenge and annotates with data useful for the client.
Variables challb – Wrapped ChallengeBody.
acme_type = NotImplemented
challb
class [Link](**kwargs)
Bases: [Link]
Client annotated KeyAuthorizationChallenge challenge.
response_and_validation(*args, **kwargs)
Generate response and validation.
account_key
challb
domain
class [Link](**kwargs)
Bases: [Link]
Client annotated “dns” ACME challenge.
acme_type
alias of [Link]
challb
domain
certbot.crypto_util module
Certbot client crypto utility functions.
certbot.crypto_util.init_save_key(key_size, key_dir, key_type=’rsa’, ellip-
tic_curve=’secp256r1’, keyname=’[Link]’)
Initializes and saves a privkey.
Inits key and saves it in PEM format on the filesystem.
Note: keyname is the attempted filename, it may be different if a file already exists at the path.
Parameters
• key_size (int) – key size in bits if key size is rsa.
• key_dir (str) – Key save directory.
• key_type (str) – Key Type [rsa, ecdsa]
• elliptic_curve (str) – Name of the elliptic curve if key type is ecdsa.
• keyname (str) – Filename of key
Returns Key
Return type [Link]
Raises ValueError – If unable to generate the key given key_size.
certbot.crypto_util.verify_renewable_cert_sig(renewable_cert)
Verifies the signature of a RenewableCert object.
Parameters renewable_cert ([Link]) – cert to verify
Raises [Link] – If signature verification fails.
certbot.crypto_util.verify_signed_payload(public_key, signature, payload, signa-
ture_hash_algorithm)
Check the signature of a payload.
Parameters
• public_key (RSAPublicKey/EllipticCurvePublicKey) – the public_key to
check signature
• signature (bytes) – the signature bytes
• payload (bytes) – the payload bytes
Raises
• InvalidSignature – If signature verification fails.
certbot.crypto_util.verify_cert_matches_priv_key(cert_path, key_path)
Verifies that the private key and cert match.
Parameters
• cert_path (str) – path to a cert in PEM format
• key_path (str) – path to a private key file
Raises [Link] – If they don’t match.
certbot.crypto_util.verify_fullchain(renewable_cert)
Verifies that fullchain is indeed cert concatenated with chain.
Parameters renewable_cert ([Link]) – cert to verify
Raises [Link] – If cert and chain do not combine to fullchain.
certbot.crypto_util.pyopenssl_load_certificate(data)
Load PEM/DER certificate.
Raises [Link] –
certbot.crypto_util.get_sans_from_cert(cert, typ=1)
Get a list of Subject Alternative Names from a certificate.
Parameters
• cert (str) – Certificate (encoded).
• typ – crypto.FILETYPE_PEM or crypto.FILETYPE_ASN1
Returns A list of Subject Alternative Names.
Return type list
certbot.crypto_util.get_names_from_cert(csr, typ=1)
Get a list of domains from a cert, including the CN if it is set.
Parameters
• cert (str) – Certificate (encoded).
• typ – crypto.FILETYPE_PEM or crypto.FILETYPE_ASN1
Returns A list of domain names.
Return type list
certbot.crypto_util.dump_pyopenssl_chain(chain, filetype=1)
Dump certificate chain into a bundle.
Parameters chain (list) – List of crypto.X509 (or wrapped in [Link].
ComparableX509).
certbot.crypto_util.notBefore(cert_path)
When does the cert at cert_path start being valid?
Parameters cert_path (str) – path to a cert in PEM format
Returns the notBefore value from the cert at cert_path
Return type [Link]
certbot.crypto_util.notAfter(cert_path)
When does the cert at cert_path stop being valid?
[Link] module
Certbot client errors.
exception [Link]
Bases: Exception
Generic Certbot client error.
exception [Link]
Bases: [Link]
Generic AccountStorage error.
exception [Link]
Bases: [Link]
Account not found error.
exception [Link]
Bases: [Link]
Certbot Reverter error.
exception [Link]
Bases: [Link]
Subprocess handling error.
exception [Link]
Bases: [Link]
Generic CertStorage error.
exception [Link]
Bases: [Link]
Failed to find a hook command in the PATH.
exception [Link]
Bases: [Link]
A Unix signal was received while in the ErrorHandler context manager.
exception [Link]
Bases: [Link]
Multiple lineages matched what should have been a unique result.
exception [Link]
Bases: [Link]
File locking error.
exception [Link]
Bases: [Link]
Authorization error.
exception [Link](failed_achalls)
Bases: [Link]
Failed challenges error.
Variables failed_achalls (set) – Failed AnnotatedChallenge instances.
exception [Link]
Bases: [Link]
Certbot Plugin error.
exception [Link]
Bases: [Link]
Enhancement was already set
exception [Link]
Bases: [Link]
A problem with plugin/configurator selection or setup
exception [Link]
Bases: [Link]
Certbot No Installation error.
exception [Link]
Bases: [Link]
Certbot Misconfiguration error.
exception [Link]
Bases: [Link]
Certbot Plugin function not supported error.
exception [Link]
Bases: [Link]
Certbot Plugin Storage error.
exception [Link](socket_error, port)
Bases: [Link]
Standalone plugin bind error.
exception [Link]
Bases: [Link]
Configuration sanity error.
exception [Link]
Bases: [Link]
A command line argument was missing in noninteractive usage
[Link] module
Certbot client interfaces.
class [Link]
Bases: object
Accounts storage interface.
find_all()
Find all accounts.
Returns All found accounts.
Return type list
load(account_id)
Load an account by its id.
Raises
• AccountNotFound – if account could not be found
• AccountStorageError – if account could not be loaded
save(account, client)
Save account.
Raises AccountStorageError – if account could not be saved
interface [Link]
IPlugin factory.
Objects providing this interface will be called without satisfying any entry point “extras” (extra dependencies)
you might have defined for your plugin, e.g (excerpt from [Link] script):
setup(
...
entry_points={
'[Link]': [
'name=example_project.plugin[plugin_deps]',
],
},
extras_require={
'plugin_deps': ['dep1', 'dep2'],
}
)
Therefore, make sure such objects are importable and usable without extras. This is necessary, because CLI
does the following operations (in order):
• loads an entry point,
• calls inject_parser_options,
• requires an entry point,
• creates plugin instance (__call__).
description
Short plugin description
__call__(config, name)
Create new IPlugin.
Parameters
• config (IConfig) – Configuration.
• name (str) – Unique plugin name.
inject_parser_options(parser, name)
Inject argument parser options (flags).
1. Be nice and prepend all options and destinations with option_namespace and dest_namespace.
2. Inject options (flags) only. Positional arguments are not allowed, as this would break the CLI.
Parameters
• parser (ArgumentParser) – (Almost) top-level CLI parser.
• name (str) – Unique plugin name.
interface [Link]
Certbot plugin.
prepare()
Prepare the plugin.
Finish up any additional initialization.
Raises
• PluginError – when full initialization cannot be completed.
Warning: The values stored in the configuration have not been filtered, stripped or sanitized.
server
ACME Directory Resource URI.
email
Email used for registration and recovery contact. Use comma to register multiple emails, ex:
u1@[Link],u2@[Link]. (default: Ask).
rsa_key_size
Size of the RSA key.
elliptic_curve
The SECG elliptic curve name to use. Please see RFC 8446 for supported values.
key_type
Type of generated private key(Only ONE per invocation can be provided at this time)
must_staple
Adds the OCSP Must Staple extension to the certificate. Autoconfigures OCSP Stapling for supported
setups (Apache version >= 2.3.3 ).
config_dir
Configuration directory.
work_dir
Working directory.
accounts_dir
Directory where all account information is stored.
backup_dir
Configuration backups directory.
csr_dir
Directory where newly generated Certificate Signing Requests (CSRs) are saved.
in_progress_dir
Directory used before a permanent checkpoint is finalized.
key_dir
Keys storage.
temp_checkpoint_dir
Temporary checkpoint directory.
no_verify_ssl
Disable verification of the ACME server’s certificate.
http01_port
Port used in the http-01 challenge. This only affects the port Certbot listens on. A conforming ACME
server will still attempt to connect on port 80.
http01_address
The address the server listens to during http-01 challenge.
https_port
Port used to serve HTTPS. This affects which port Nginx will listen on after a LE certificate is installed.
pref_challs
Sorted user specified preferred challengestype strings with the most preferred challenge listed first
allow_subset_of_names
When performing domain validation, do not consider it a failure if authorizations can not be obtained for
a strict subset of the requested domains. This may be useful for allowing renewals for multiple domains to
succeed even if some domains no longer point at this system. This is a boolean
strict_permissions
Require that all configuration files are owned by the current user; only needed if your config is somewhere
unsafe like /tmp/.This is a boolean
disable_renew_updates
If updates provided by installer enhancements when Certbot is being run with “renew” verb should be
disabled.
preferred_chain
If the CA offers multiple certificate chains, prefer the chain with an issuer matching this Subject Common
Name. If no match, the default offered chain will be used.
interface [Link]
Extends: [Link]
Generic Certbot Installer Interface.
Represents any server that an X509 certificate can be placed.
It is assumed that save() is the only method that finalizes a checkpoint. This is important to ensure that
checkpoints are restored in a consistent manner if requested by the user or in case of an error.
Using [Link] to implement checkpoints, rollback, and recovery can dramatically
simplify plugin development.
get_all_names()
Returns all names that may be authenticated.
Return type [Link] of str
deploy_cert(domain, cert_path, key_path, chain_path, fullchain_path)
Deploy certificate.
Parameters
• domain (str) – domain to deploy certificate file
• cert_path (str) – absolute path to the certificate file
• key_path (str) – absolute path to the private key file
• chain_path (str) – absolute path to the certificate chain file
• fullchain_path (str) – absolute path to the certificate fullchain file (cert plus chain)
Raises PluginError – when cert cannot be deployed
enhance(domain, enhancement, options=None)
Perform a configuration enhancement.
Parameters
• domain (str) – domain for which to provide enhancement
• enhancement (str) – An enhancement as defined in ENHANCEMENTS
• options – Flexible options parameter for enhancement. Check documentation of
ENHANCEMENTS for expected options for each enhancement.
Raises PluginError – If Enhancement is not supported, or if an error occurs during the
enhancement.
supported_enhancements()
Returns a [Link] of supported enhancements.
Returns supported enhancements which should be a subset of ENHANCEMENTS
Return type [Link] of str
save(title=None, temporary=False)
Saves all changes to the configuration files.
Both title and temporary are needed because a save may be intended to be permanent, but the save is not
ready to be a full checkpoint.
It is assumed that at most one checkpoint is finalized by this method. Additionally, if an exception is
raised, it is assumed a new checkpoint was not finalized.
Parameters
• title (str) – The title of the save. If a title is given, the configuration will be saved as
a new checkpoint and put in a timestamped directory. title has no effect if temporary
is true.
• temporary (bool) – Indicates whether the changes made will be quickly reversed in
the future (challenges)
Raises PluginError – when save is unsuccessful
rollback_checkpoints(rollback=1)
Revert rollback number of configuration checkpoints.
Raises PluginError – when configuration cannot be fully reverted
recovery_routine()
Revert configuration to most recent finalized checkpoint.
Remove all changes (temporary and permanent) that have not been finalized. This is useful to protect
against crashes and other execution interruptions.
Raises [Link] – If unable to recover the configuration
config_test()
Make sure the configuration is valid.
Raises MisconfigurationError – when the config is not in a usable state
restart()
Restart or refresh the server content.
Raises PluginError – when server cannot be restarted
interface [Link]
Generic display.
notification(message, pause, wrap=True, force_interactive=False)
Displays a string message
Parameters
• message (str) – Message to display
• pause (bool) – Whether or not the application should pause for confirmation (if avail-
able)
• wrap (bool) – Whether or not the application should wrap text
• force_interactive (bool) – True if it’s safe to prompt the user because it won’t
cause any workflow regressions
menu(message, choices, ok_label=None, cancel_label=None, help_label=None, default=None,
cli_flag=None, force_interactive=False)
Displays a generic menu.
When not setting force_interactive=True, you must provide a default value.
Parameters
• message (str) – message to display
• choices (list of tuple() or str) – choices
• ok_label (str) – label for OK button (UNUSED)
• cancel_label (str) – label for Cancel button (UNUSED)
• help_label (str) – label for Help button (UNUSED)
• default (int) – default (non-interactive) choice from the menu
• cli_flag (str) – to automate choice from the menu, eg “–keep”
• force_interactive (bool) – True if it’s safe to prompt the user because it won’t
cause any workflow regressions
Returns tuple of (code, index) where code - str display exit code index - int index of the
user’s selection
Raises [Link] – if called in non-interactive mode without a
default set
input(message, default=None, cli_args=None, force_interactive=False)
Accept input from the user.
When not setting force_interactive=True, you must provide a default value.
Parameters
• message (str) – message to display to the user
• default (str) – default (non-interactive) response to prompt
• force_interactive (bool) – True if it’s safe to prompt the user because it won’t
cause any workflow regressions
Returns tuple of (code, input) where code - str display exit code input - str of the user’s
input
Return type tuple
Raises [Link] – if called in non-interactive mode without a
default set
yesno(message, yes_label=’Yes’, no_label=’No’, default=None, cli_args=None,
force_interactive=False)
Query the user with a yes/no question.
Yes and No label must begin with different letters.
When not setting force_interactive=True, you must provide a default value.
Parameters
• message (str) – question for the user
MEDIUM_PRIORITY
Used to denote medium priority messages
LOW_PRIORITY
Used to denote low priority messages
add_message(self, msg, priority, on_crash=True)
Adds msg to the list of messages to be printed.
Parameters
• msg (str) – Message to be displayed to the user.
• priority (int) – One of HIGH_PRIORITY, MEDIUM_PRIORITY, or
LOW_PRIORITY.
• on_crash (bool) – Whether or not the message should be printed if the program exits
abnormally.
print_messages(self )
Prints messages to the user and clears the message queue.
class [Link]
Bases: object
Interface to a certificate lineage.
cert_path
Path to the certificate file.
Return type str
key_path
Path to the private key file.
Return type str
chain_path
Path to the certificate chain file.
Return type str
fullchain_path
Path to the full chain file.
The full chain is the certificate file plus the chain file.
Return type str
lineagename
Name given to the certificate lineage.
Return type str
names()
What are the subject names of this certificate?
Returns the subject names
Return type list of str
Raises CertStorageError – if could not find cert file.
class [Link]
Bases: object
Interface for update types not currently specified by Certbot.
This class allows plugins to perform types of updates that Certbot hasn’t defined (yet).
To make use of this interface, the installer should implement the interface methods, and inter-
[Link](InstallerClass) should be called from the installer code.
The plugins implementing this enhancement are responsible of handling the saving of configuration checkpoints
as well as other calls to interface methods of [Link] such as prepare() and restart()
generic_updates(lineage, *args, **kwargs)
Perform any update types defined by the installer.
If an installer is a subclass of the class containing this method, this function will always be called when
“certbot renew” is run. If the update defined by the installer should be run conditionally, the installer needs
to handle checking the conditions itself.
This method is called once for each lineage.
Parameters lineage (RenewableCert) – Certificate lineage object
class [Link]
Bases: object
Interface for update types run when a lineage is renewed
This class allows plugins to perform types of updates that need to run at lineage renewal that Certbot hasn’t
defined (yet).
To make use of this interface, the installer should implement the interface methods, and inter-
[Link](InstallerClass) should be called from the installer code.
renew_deploy(lineage, *args, **kwargs)
Perform updates defined by installer when a certificate has been renewed
If an installer is a subclass of the class containing this method, this function will always be called when a
certficate has been renewed by running “certbot renew”. For example if a plugin needs to copy a certificate
over, or change configuration based on the new certificate.
This method is called once for each lineage renewed
Parameters lineage (RenewableCert) – Certificate lineage object
[Link] module
Certbot main public entry point.
[Link](cli_args=None)
Run Certbot.
Parameters cli_args (list of str) – command line to Certbot, defaults to [Link][1:]
Returns value for [Link] about the exit status of Certbot
Return type str or int or None
[Link] package
Tools for checking certificate revocation.
class [Link](enforce_openssl_binary_usage=False)
Bases: object
This class figures out OCSP checking on this system, and performs it.
ocsp_revoked(cert)
Get revoked status for a particular cert version.
[Link] module
Reverter class saves configuration checkpoints and allows for recovery.
class [Link](config)
Bases: object
Reverter Class - save and revert configuration checkpoints.
This class can be used by the plugins, especially Installers, to undo changes made to the user’s system. Modifi-
cations to files and commands to do undo actions taken by the plugin should be registered with this class before
the action is taken.
Once a change has been registered with this class, there are three states the change can be in. First,
the change can be a temporary change. This should be used for changes that will soon be re-
verted, such as config changes for the purpose of solving a challenge. Changes are added to this state
through calls to add_to_temp_checkpoint() and reverted when revert_temporary_config()
or recovery_routine() is called.
The second state a change can be in is in progress. These changes are not temporary, however, they also have
not been finalized in a checkpoint. A change must become in progress before it can be finalized. Changes are
added to this state through calls to add_to_checkpoint() and reverted when recovery_routine()
is called.
The last state a change can be in is finalized in a checkpoint. A change is put into this state by first becoming
an in progress change and then calling finalize_checkpoint(). Changes in this state can be reverted
through calls to rollback_checkpoints().
As a final note, creating new files and registering undo commands are handled specially and use the methods
register_file_creation() and register_undo_command() respectively. Both of these methods
can be used to create either temporary or in progress changes.
revert_temporary_config()
Reload users original configuration files after a temporary save.
This function should reinstall the users original configuration files for all saves with temporary=True
Warning: This function does not enforce order of operations in terms of file modification vs. com-
mand registration. All undo commands are run first before all normal files are reverted to their previous
state. If you need to maintain strict order, you may create checkpoints before and after the the command
registration. This function may be improved in the future based on demand.
Parameters
• temporary (bool) – Whether the command should be saved in the IN_PROGRESS or
TEMPORARY checkpoints.
• command (list of str) – Command to be run.
recovery_routine()
Revert configuration to most recent finalized checkpoint.
Remove all changes (temporary and permanent) that have not been finalized. This is useful to protect
against crashes and other execution interruptions.
Raises [Link] – If unable to recover the configuration
finalize_checkpoint(title)
Finalize the checkpoint.
Timestamps and permanently saves all changes made through the use of add_to_checkpoint() and
register_file_creation()
Parameters title (str) – Title describing checkpoint
Raises [Link] – when the checkpoint is not able to be final-
ized.
[Link] module
Utilities for all Certbot.
class [Link](file, pem)
Bases: tuple
file
Alias for field number 0
pem
Alias for field number 1
class [Link](file, data, form)
Bases: tuple
data
Alias for field number 1
file
Alias for field number 0
form
Alias for field number 2
[Link].env_no_snap_for_external_calls()
When Certbot is run inside a Snap, certain environment variables are modified. But Certbot sometimes calls out
to external programs, since it uses classic confinement. When we do that, we must modify the env to remove our
modifications so it will use the system’s libraries, since they may be incompatible with the versions of libraries
included in the Snap. For example, apachectl, Nginx, and anything run from inside a hook should call this
function and pass the results into the env argument of [Link].
Returns A modified copy of [Link] ready to pass to Popen
Return type dict
[Link].run_script(params, log=<bound method [Link] of <Logger [Link] (WARN-
ING)>>)
Run the script with the given params.
Parameters
• params (list) – List of parameters to pass to Popen
• log (callable) – Logger method to use for errors
[Link].exe_exists(exe)
Determine whether path/name refers to an executable.
[Link].get_python_os_info(pretty=False)
Get Operating System type/distribution and major version using python platform module
Parameters pretty (bool) – If the returned OS name should be in longer (pretty) form
Returns (os_name, os_version)
Return type tuple of str
[Link].safe_email(email)
Scrub email address before using it.
class [Link](option_strings, dest, nargs=None,
const=None, default=None, type=None,
choices=None, required=False, help=None,
metavar=None)
Bases: [Link]
Action to log a warning when an argument is used.
[Link].add_deprecated_argument(add_argument, argument_name, nargs)
Adds a deprecated argument with the name argument_name.
Deprecated arguments are not shown in the help. If they are used on the command line, a warning is shown
stating that the argument is deprecated and no other action is taken.
Parameters
• add_argument (callable) – Function that adds arguments to an argument
parser/group.
• argument_name (str) – Name of deprecated argument.
• nargs – Value for nargs when adding the argument to argparse.
[Link].enforce_le_validity(domain)
Checks that Let’s Encrypt will consider domain to be valid.
Parameters domain (str or unicode) – FQDN to check
Returns The domain cast to str, with ASCII-only contents
Return type str
Raises ConfigurationError – for invalid domains and cases where Let’s Encrypt currently
will not issue certificates
[Link].enforce_domain_sanity(domain)
Method which validates domain value and errors out if the requirements are not met.
Parameters domain (str or unicode) – Domain to check
Raises ConfigurationError – for invalid domains and cases where Let’s Encrypt currently
will not issue certificates
Returns The domain cast to str, with ASCII-only contents
Return type str
[Link].is_wildcard_domain(domain)
“Is domain a wildcard domain?
Parameters domain (bytes or str or unicode) – domain to check
Returns True if domain is a wildcard, otherwise, False
Return type bool
[Link].get_strict_version(normalized)
Converts a normalized version to a strict version.
Parameters normalized (str) – normalized version string
Returns An equivalent strict version
Return type [Link]
[Link].is_staging(srv)
Determine whether a given ACME server is a known test / staging server.
Parameters srv (str) – the URI for the ACME server
Returns True iff srv is a known test / staging server
Rtype bool
[Link].atexit_register(func, *args, **kwargs)
Sets func to be called before the program exits.
Special care is taken to ensure func is only called when the process that first imports this module exits rather
than any child processes.
Parameters func (function) – function to be called in case of an error
TEN
• genindex
• modindex
• search
121
Certbot Documentation, Release 1.11.0.dev0
c
certbot, 57
[Link], 97
[Link], 57
[Link], 57
[Link], 60
[Link], 61
certbot.crypto_util, 98
[Link], 81
[Link], 81
[Link], 82
[Link], 102
[Link], 104
[Link], 113
[Link], 113
[Link], 87
[Link], 87
[Link].dns_common, 90
[Link].dns_common_lexicon, 91
[Link].dns_test_common, 92
[Link].dns_test_common_lexicon,
92
[Link], 93
[Link], 94
[Link], 95
[Link], 114
[Link], 95
[Link].acme_util, 95
[Link], 96
[Link], 116
123
Certbot Documentation, Release 1.11.0.dev0
125
Certbot Documentation, Release 1.11.0.dev0
126 Index
Certbot Documentation, Release 1.11.0.dev0
Index 127
Certbot Documentation, Release 1.11.0.dev0
128 Index
Certbot Documentation, Release 1.11.0.dev0
Index 129
Certbot Documentation, Release 1.11.0.dev0
130 Index
Certbot Documentation, Release 1.11.0.dev0
Index 131
Certbot Documentation, Release 1.11.0.dev0
132 Index
Certbot Documentation, Release 1.11.0.dev0
V
valid_csr() (in module certbot.crypto_util), 99
valid_privkey() (in module certbot.crypto_util), 100
validate_file() (in module [Link].dns_common),
90
validate_file_permissions() (in module cert-
[Link].dns_common), 90
validated_directory() (in module [Link]), 82
validated_input() (in module [Link]), 82
vector_path() (in module [Link]), 96
verify_cert_matches_priv_key() (in module cert-
bot.crypto_util), 101
verify_fullchain() (in module certbot.crypto_util), 101
verify_renewable_cert() (in module certbot.crypto_util),
100
verify_renewable_cert_sig() (in module cert-
bot.crypto_util), 100
verify_signed_payload() (in module certbot.crypto_util),
100
version ([Link].uname_result attribute), 76
W
wait() (in module [Link]), 77
wait3() (in module [Link]), 77
wait4() (in module [Link]), 77
waitid() (in module [Link]), 77
waitid_result (class in [Link]), 77
waitpid() (in module [Link]), 78
walk() (in module [Link]), 78
WCOREDUMP() (in module [Link]), 62
WEXITSTATUS() (in module [Link]), 62
WIFCONTINUED() (in module [Link]), 62
WIFEXITED() (in module [Link]), 62
WIFSIGNALED() (in module [Link]), 62
WIFSTOPPED() (in module [Link]), 63
work_dir ([Link] attribute), 107
write() (in module [Link]), 78
write() (in module [Link].dns_test_common), 92
writev() (in module [Link]), 78
WSTOPSIG() (in module [Link]), 63
WTERMSIG() (in module [Link]), 63
Y
yesno() ([Link] method), 84
yesno() ([Link]
method), 86
yesno() ([Link] method), 110
Index 133