4c6d3e0ddeeaf6eb1cce5a95bde2aa34e9800db1
SafelineAPI
Small CLI to request and upsert TLS certificates (DNS-01) with multiple DNS provider backends. This repo now includes Cloudflare DNS provider support via the lego provider.
Prerequisites
- Go toolchain (only required to build from source)
- A SafeLine API token (set in
config.json) - Cloudflare API token (scoped) or Global API key + account email
Quick start
-
Copy
config.example.jsontoconfig.jsonand fill in your values. -
Build (optional):
cd C:\Users\samge\coding\SafelineAPI-1
go build -o safelineApi.exe ./cmd/safelineApi
- Run:
# using built binary
.\safelineApi.exe
# or directly with go
go run ./cmd/safelineApi -- -t "<SafeLineApiToken>" -D "Cloudflare" -e "you@example.com"
Configuration notes
- The main configuration file is
config.jsonin the project root. - To use Cloudflare for DNS-01, set
ApplyCert.DNSProviderConfig.DNSProvidertoCloudflareand setApplyCert.DNSProviderConfig.Cloudflare.APITokento a scoped API token withZone:DNS:Editpermission. - If you must use the global API key, set
Cloudflare.APIKeyandCloudflare.Emailinstead (less secure).
Docs
- See
docs/CONFIGURATION.mdfor detailed configuration and troubleshooting steps. - See
docs/cloudflare.mdfor a short Cloudflare-specific guide.
Security
- Prefer scoped API tokens over global keys.
- Keep
config.jsonout of source control; use environment variables or secret management in production.
Need anything else?
- I can add a small PowerShell script to run the app with environment variable support or create a release artifact (Windows exe) if you'd like.
Linux usage (systemd)
Most users run this on a Linux host. Below are recommended steps to install and run SafelineAPI as a service.
- Build on the target machine (or cross-compile):
cd /opt
git clone <your-repo-url> safelineapi
cd safelineapi
go build -o safelineApi ./cmd/safelineApi
-
Place your
config.jsonin/opt/safelineapi/config.json(or edit accordingly). You can useconfig.example.jsonas a starting point. -
Install systemd unit (example unit available at
contrib/safelineapi.service):
sudo cp contrib/safelineapi.service /etc/systemd/system/
sudo useradd --system --no-create-home safeline || true
sudo chown -R safeline:safeline /opt/safelineapi
sudo systemctl daemon-reload
sudo systemctl enable --now safelineapi.service
sudo journalctl -u safelineapi.service -f
- Alternatively run with the provided helper script (uses environment variables or builds if missing):
chmod +x scripts/run.sh
SAFELINE_API_TOKEN="..." DNS_PROVIDER=Cloudflare CONTACT_EMAIL="you@example.com" ./scripts/run.sh
Notes
- The
contrib/safelineapi.serviceunit assumes files live in/opt/safelineapiand the binary is/opt/safelineapi/safelineApi. Adjust paths to fit your setup. - For production, run the service as a dedicated unprivileged user and keep
config.jsonpermissions restricted.
Description
Releases
2
Release v1.0.3
Latest
Languages
Go
84.6%
Shell
11.4%
Makefile
4%