BoxLang π A New JVM Dynamic Language Learn More...
A CommandBox module that wraps the Lego ACME client for easy SSL certificate generation
This module provides a convenient way to generate SSL certificates using Let's Encrypt directly from your CommandBox CLI. It integrates the Lego ACME client, allowing you to generate certificates using DNS challenges with support for multiple DNS providers.
Lego uses DNS-01 challenge for domain validation instead of the
traditional HTTP-01 challenge (which uses the .well-known
folder). This means:
This method is more reliable than HTTP validation as it works even for internal/private domains and doesn't require public web server access.
scoop install lego
Using PowerShell Script (Recommended):
Manual Installation:
lego.exe to a folder (e.g.,
C:\Program Files\Lego\)C:\Program Files\Lego\)Using Homebrew:
brew install lego
Using package managers:
For Ubuntu/Debian:
sudo snap install lego
For Arch Linux:
yay -S lego
Manual Installation:
# Download latest release
curl -L "https://github.com/go-acme/lego/releases/download/v4.x.x/lego_v4.x.x_linux_amd64.tar.gz" -o lego.tar.gz
# Extract
tar xf lego.tar.gz
# Move to system path
sudo mv lego /usr/local/bin/
# Verify installation
lego --version
After installation, verify Lego is available in your PATH:
lego --version
You should see output like:
lego version x.x.x ...
If you get "command not found" or "lego is not recognized", either:
# Check if lego exists in your current directory
dir lego.exe
# Check if lego exists in your PATH by seeing all locations
where lego
# Check if lego exists in your PATH
which lego
# Check all folders in your PATH
echo $PATH
If Lego isn't found, ensure you've:
β Install Lego using your OS-specific method
β Verify Lego is in
your PATH using lego --version
β Configure your DNS provider credentials
β Install the
CommandBox module
Install this module by running the following command in CommandBox:
box install commandbox-cblego
This module requires you to have:
You can find detailed information about required API keys, tokens, and environment variables for your specific DNS provider in the Lego DNS provider documentation.
This is a list of DNS providers supported by the lego ACME client{:target="_blank"}. Each provider link will open in a new tab.
| Provider | Website |
|---|---|
| Active24 | active24 |
| Akamai EdgeDNS | edgedns |
| Alibaba Cloud DNS | alidns |
| all-inkl | allinkl |
| Amazon Lightsail | lightsail |
| Amazon Route 53 | route53 |
| ArvanCloud | arvancloud |
| Aurora DNS | auroradns |
| Autodns | autodns |
| Axelname | axelname |
| Azure (deprecated) | azure |
| Azure DNS | azuredns |
| Baidu Cloud | baiducloud |
| Bindman | bindman |
| Bluecat | bluecat |
| BookMyName | bookmyname |
| Brandit (deprecated) | brandit |
| Bunny | bunny |
| Checkdomain | checkdomain |
| Civo | civo |
| Cloud.ru | cloudru |
| CloudDNS | clouddns |
| Cloudflare | cloudflare |
| ClouDNS | cloudns |
| CloudXNS (Deprecated) | cloudxns |
| ConoHa | conoha |
| Constellix | constellix |
| Core-Networks | corenetworks |
| CPanel/WHM | cpanel |
| Derak Cloud | derak |
| deSEC.io | desec |
| Designate DNSaaS for Openstack | designate |
| Digital Ocean | digitalocean |
| DirectAdmin | directadmin |
| DNS Made Easy | dnsmadeeasy |
| dnsHome.de | dnshomede |
| DNSimple | dnsimple |
| DNSPod (deprecated) | dnspod |
| Domain Offensive (do.de) | dode |
| Domeneshop | domeneshop |
| DreamHost | dreamhost |
| Duck DNS | duckdns |
| Dyn | dyn |
| Dynu | dynu |
| EasyDNS | easydns |
| Efficient IP | efficientip |
| Epik | epik |
| Exoscale | exoscale |
| External program | exec |
| F5 XC | f5xc |
| freemyip.com | freemyip |
| G-Core | gcore |
| Gandi | gandi |
| Gandi Live DNS (v5) | gandiv5 |
| Glesys | glesys |
| Go Daddy | godaddy |
| Google Cloud | gcloud |
| Google Domains | googledomains |
| Hetzner | hetzner |
| Hosting.de | hostingde |
| Hosttech | hosttech |
| HTTP request | httpreq |
| http.net | httpnet |
| Huawei Cloud | huaweicloud |
| Hurricane Electric DNS | hurricane |
| HyperOne | hyperone |
| IBM Cloud (SoftLayer) | ibmcloud |
| IIJ DNS Platform Service | iijdpf |
| Infoblox | infoblox |
| Infomaniak | infomaniak |
| Internet Initiative Japan | iij |
| Internet.bs | internetbs |
| INWX | inwx |
| Ionos | ionos |
| IPv64 | ipv64 |
| iwantmyname | iwantmyname |
| Joker | joker |
| Joohoi's ACME-DNS | acme-dns |
| Liara | liara |
| Lima-City | limacity |
| Linode (v4) | linode |
| Liquid Web | liquidweb |
| Loopia | loopia |
| LuaDNS | luadns |
| Mail-in-a-Box | mailinabox |
| ManageEngine CloudDNS | manageengine |
| Manual | manual |
| Metaname | metaname |
| Metaregistrar | metaregistrar |
| mijn.host | mijnhost |
| Mittwald | mittwald |
| myaddr.{tools,dev,io} | myaddr |
| MyDNS.jp | mydnsjp |
| MythicBeasts | mythicbeasts |
| Name.com | namedotcom |
| Namecheap | namecheap |
| Namesilo | namesilo |
| NearlyFreeSpeech.NET | nearlyfreespeech |
| Netcup | netcup |
| Netlify | netlify |
| Nicmanager | nicmanager |
| NIFCloud | nifcloud |
| Njalla | njalla |
| Nodion | nodion |
| NS1 | ns1 |
| Open Telekom Cloud | otc |
| Oracle Cloud | oraclecloud |
| OVH | ovh |
| plesk.com | plesk |
| Porkbun | porkbun |
| PowerDNS | pdns |
| Rackspace | rackspace |
| Rain Yun/ι¨δΊ | rainyun |
| RcodeZero | rcodezero |
| reg.ru | regru |
| Regfish | regfish |
| RFC2136 | rfc2136 |
| RimuHosting | rimuhosting |
| Sakura Cloud | sakuracloud |
| Scaleway | scaleway |
| Selectel | selectel |
| Selectel v2 | selectelv2 |
| SelfHost.(de|eu) | selfhostde |
| Servercow | servercow |
| Shellrent | shellrent |
| Simply.com | simply |
| Sonic | sonic |
| Spaceship | spaceship |
| Stackpath | stackpath |
| Technitium | technitium |
| Tencent Cloud DNS | tencentcloud |
| Timeweb Cloud | timewebcloud |
| TransIP | transip |
| UKFast SafeDNS | safedns |
| Ultradns | ultradns |
| Variomedia | variomedia |
| VegaDNS | vegadns |
| Vercel | vercel |
| Versio.[nl|eu|uk] | versio |
| VinylDNS | vinyldns |
| VK Cloud | vkcloud |
| Volcano Engine/η«ε±±εΌζ | volcengine |
| Vscale | vscale |
| Vultr | vultr |
| Webnames | webnames |
| Websupport | websupport |
| WEDOS | wedos |
| West.cn/θ₯Ώι¨ζ°η | westcn |
| Yandex 360 | yandex360 |
| Yandex Cloud | yandexcloud |
| Yandex PDD | yandex |
| Zone.ee | zoneee |
| Zonomi | zonomi |
Here are examples for common DNS providers:
# Using Token Authentication (Recommended)
export CLOUDFLARE_DNS_API_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
export CLOUDFLARE_ZONE_API_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# Or using a single token with both permissions
export CLOUDFLARE_DNS_API_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# Using Email+Key Authentication (Legacy)
export [email protected]
export CLOUDFLARE_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# Optional: Specify Zone Name (useful for troubleshooting)
export CLOUDFLARE_ZONE_NAME=yourdomain.com
# Optional: Set propagation timeout (in seconds)
export CLOUDFLARE_PROPAGATION_TIMEOUT=300
# Using direct values
export EASYDNS_TOKEN=XXXXXXXXXXXXXXXX
export EASYDNS_KEY=XXXXXXXXXXXXXXXX
# Or using files
export EASYDNS_TOKEN_FILE=/path/to/token/file
export EASYDNS_KEY_FILE=/path/to/key/file
cblego --accept-tos \
--email [email protected] \
--dns easydns \
-d example.com \
run
EASYDNS_TOKEN=XXXXXXXXXXXXXXXX \
EASYDNS_KEY=XXXXXXXXXXXXXXXX \
cblego --accept-tos \
--email [email protected] \
--dns easydns \
-d '*.example.com' \
run
Note:
cblego --accept-tos \
--server https://acme-staging-v02.api.letsencrypt.org/directory \
--email [email protected] \
--dns easydns \
--domains dev.example.com \
--path ./dev-certs \
run
If you're experiencing DNS propagation issues, you can specify custom DNS resolvers:
cblego --accept-tos \
--email [email protected] \
--dns cloudflare \
--dns.resolvers="1.1.1.1:53" \
-d example.com \
run
For EasyDNS specifically, you might want to use their own nameservers:
cblego --accept-tos \
--email [email protected] \
--dns easydns \
--dns.resolvers="dns1.easydns.com:53,dns2.easydns.com:53" \
-d example.com \
run
This is particularly helpful when:
If you encounter authentication issues, follow these steps:
# For easyDNS
echo $EASYDNS_TOKEN
echo $EASYDNS_KEY
# For Cloudflare
echo $CLOUDFLARE_DNS_API_TOKEN
echo $CLOUDFLARE_EMAIL
CLOUDFLARE_ZONE_NAME=yourdomain.com to
your environmentFor easyDNS:
# Test API access
curl -H "Authorization: Basic $(echo -n "XXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXX" | base64)" \
https://rest.easydns.net/domain/list
# Test with custom resolvers
EASYDNS_TOKEN=XXXXXXXXXXXXXXXX \
EASYDNS_KEY=XXXXXXXXXXXXXXXX \
cblego --accept-tos \
--email [email protected] \
--dns easydns \
--dns.resolvers="dns1.easydns.com:53,dns2.easydns.com:53" \
-d example.com \
run
If you have domains with multi-part TLDs (like .co.uk domains), using EasyDNS's own nameservers as resolvers can help avoid permission errors.
For Cloudflare:
# Test API token validity
curl -X GET "https://api.cloudflare.com/client/v4/user/tokens/verify" \
-H "Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-H "Content-Type:application/json"
# Test zone access
curl -X GET "https://api.cloudflare.com/client/v4/zones?name=yourdomain.com" \
-H "Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-H "Content-Type:application/json"
LEGO_DEBUG=1 cblego --accept-tos \
--email [email protected] \
--dns easydns \
--domains example.com \
run
The module supports over 80 DNS providers that Lego supports, including:
Check if your DNS provider is supported by visiting the Lego DNS provider documentation
After successful certificate generation, you'll find the following
files in your .lego directory:
certificates/domain.com.crt - Server certificate
(including CA certificate)certificates/domain.com.key - Private keycertificates/domain.com.issuer.crt - CA certificatecertificates/domain.com.json - Certificate metadataInstall this module by running the following command in CommandBox:
box install commandbox-cblego
For cloudflare
cblego run envfile=cloudflare.env staging=staging|prod path=Optinal|Path To Store Lego certificate
Example cloudflare.env file:
# Cloudflare API Configuration
CLOUDFLARE_DNS_API_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[email protected]
CLOUDFLARE_ZONE_NAME=yourdomain.com
CLOUDFLARE_PROPAGATION_TIMEOUT=300
DNS_PROVIDER=cloudflare
# For wildcard certificates, use the wildcard domain
# A wildcard covers only first-level subdomains (e.g., *.example.com covers sub.example.com but NOT sub.sub.example.com)
# Note: Wildcards do NOT cover the root domain (example.com)
DOMAINS=*.yourdomain.com
# If you need both root domain and subdomains:
# DOMAINS=yourdomain.com,*.yourdomain.com
# For specific domains without wildcards, list each required domain
# DOMAINS=yourdomain.com,www.yourdomain.com,api.yourdomain.com
[email protected]
For easydns
cblego run envfile=easydns.env staging=staging|prod path=Optinal|Path To Store Lego certificate
Example easydns.env file:
# EasyDNS API Configuration
EASYDNS_TOKEN=XXXXXXXXXXXXXXXX
EASYDNS_KEY=XXXXXXXXXXXXXXXX
# Optional: Increase propagation timeout for multi-part TLDs
EASYDNS_PROPAGATION_TIMEOUT=300
# Optional: Use EasyDNS endpoint (sandbox for testing)
EASYDNS_ENDPOINT=https://sandbox.rest.easydns.net
DNS_PROVIDER=easydns
# For wildcard certificates, use the wildcard domain
# A wildcard covers only first-level subdomains (e.g., *.example.com covers sub.example.com but NOT sub.sub.example.com)
# Note: Wildcards do NOT cover the root domain (example.com)
DOMAINS=*.yourdomain.com
# If you need both root domain and subdomains:
# DOMAINS=yourdomain.com,*.yourdomain.com
# For specific domains without wildcards, list each required domain
# DOMAINS=yourdomain.com,www.yourdomain.com,admin.yourdomain.com
[email protected]
We welcome contributions! Please see our Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.
$
box install commandbox-cblego