Module jls.net.Acme
Provides a client implementation of the Automatic Certificate Management Environment (ACME) v2 protocol.
It allows to get a certificate from an ACME server such as Let’s Encrypt. See RFC 8555.
Class Acme
| Acme:new (url, options) | Creates a new Acme client. |
| acme:getTermsOfServiceURL () | Gets the terms of service URL. |
| acme:createAccount ([contactEMails[, onlyReturnExisting]]) | Creates an account. |
| acme:orderCertificate ([domains]) | Gets a certificate. |
| acme:close () | Closes this Acme client. |
Class Acme
The Acme client class.
- Acme:new (url, options)
-
Creates a new Acme client.
The files will be created if necessary or used if existing.
Parameters:
- url string the ACME API endpoint URL for the directory resource
- options a table describing the client options
- wwwDir string The root directory of the local HTTP server (optional)
- acmeDir string The directory of the local HTTP server for the ACME challenges (optional)
- domains string the domain for which the certificate is ordered (optional)
- accountUrl string the account URL, must match the account private key (optional)
- contactEMails string the contact email for the account (optional)
- accountKeyFile string the file containing the private key for the account (optional)
- domainKeyFile string the file containing the private key for the certificate (optional)
- certificateFile string the file containing the certificate (optional)
- certificateNames table the certificate names to use for the request (optional)
- extensions table the certificate extensions to use for the request (optional)
- timeout number the timeout in seconds for the order to be ready or valid (optional)
Returns:
-
a new Acme client
Usage:
local acme = Acme:new('https://acme-v02.api.letsencrypt.org/directory', { domains = 'mydomain.fr', wwwDir = '/var/www/' })
- acme:getTermsOfServiceURL ()
-
Gets the terms of service URL.
Returns:
-
a promise that resolves to the URL
- acme:createAccount ([contactEMails[, onlyReturnExisting]])
-
Creates an account.
The account private key will be generated if not provided. If the server already has an account registered with the account key, this account will be used. Creating an account implies to agree to the terms of service.Parameters:
- contactEMails string the contact email for the account (optional)
- onlyReturnExisting boolean true to not create the account (optional)
Returns:
-
a promise that resolves to the account response as a table
- acme:orderCertificate ([domains])
-
Gets a certificate.
The account will be created if its URL is not provided. The domain private key, used for the certificate, will be generated if not provided.
The HTTP Challenge is used by default, the local HTTP server must be available to the ACME server.Parameters:
- domains string the domain for which the certificate is ordered (optional)
Returns:
-
a promise that resolves to the raw certificate
- acme:close ()
- Closes this Acme client.