Obtain or renew certificates
This guide explains various ways to get and renew a certificate.
These examples assume you have lego installed. You can get a pre-built binary from the releases page.
Quickstart
Execute the following command:
Create a .lego.yml file with the following content:
And execute:
Wildcard Certificates
Execute the following command:
Create a .lego.yml file with the following content:
And execute:
Certificates
You will find your certificates in the .lego folder of the current working directory:
where
example.com.crtis the server certificate (including the CA certificate),example.com.keyis the private key needed for the server certificate,example.com.issuer.crtis the CA certificate, andexample.com.jsoncontains some JSON encoded meta information.
For each domain, you will have a set of these four files.
For wildcard certificates (*.example.com), the filenames will look like _.example.com.crt.
The .crt and .key files are PEM-encoded x509 certificates and private keys.
If you’re looking for a cert.pem and privkey.pem, you can just use example.com.crt and example.com.key.
Using a custom certificate signing request (CSR)
The first step in the process of obtaining certificates involves creating a signing request. This CSR bundles various information, including the domain name(s) and a public key. By default, lego will hide this step from you, but if you already have a CSR, you can easily reuse it:
Execute the following command:
Create a .lego.yml file with the following content:
And execute:
lego will infer the domains to be validated based on the contents of the CSR, so make sure the CSR’s Common Name and SubjectAltNames are set correctly.
Challenge Types
-
This guide explains how to get and renew a certificate with the DNS-01 challenge.
-
This guide explains how to get and renew a certificate with the HTTP-01 challenge.
-
This guide explains how to get and renew a certificate with the TLS-ALPN-01 challenge.
-
This guide explains how to get and renew a certificate with the DNS-PERSIST-01 challenge.