Skip to main content

OpusDNS DNS Authenticator plugin for Certbot

Project description

certbot-dns-opusdns

PyPI version CI Python versions License: MIT

OpusDNS DNS Authenticator plugin for Certbot.

This plugin enables automatic DNS-01 challenge verification for Let's Encrypt certificates using OpusDNS as your DNS provider.

Features

  • Automatic DNS-01 challenge record management
  • DNS propagation polling (verifies records via 8.8.8.8 and 1.1.1.1)
  • Retry logic for rate limits and transient errors
  • Support for wildcard certificates
  • Configurable API endpoint (production/sandbox)
  • Best-effort cleanup (doesn't fail on cleanup errors)

Installation

From PyPI (recommended)

pip install certbot-dns-opusdns

From source

git clone https://github.com/OpusDNS/certbot-dns-opusdns
cd certbot-dns-opusdns
pip install .

Docker

docker build -t certbot-dns-opusdns .

Prerequisites

  1. Python 3.10+
  2. OpusDNS Account: Sign up at opusdns.com
  3. API Key: Create an API key via the OpusDNS dashboard
  4. DNS Zone: Your domain must be managed by OpusDNS

Configuration

Credentials File

Create a credentials file (e.g., ~/.secrets/certbot/opusdns.ini):

# Required: Your OpusDNS API key
dns_opusdns_api_key = opk_xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_xxxxxx

# Optional: API endpoint (defaults to https://api.opusdns.com)
# dns_opusdns_api_endpoint = https://api.opusdns.com

# Optional: TTL for TXT records in seconds (defaults to 60)
# dns_opusdns_ttl = 60

Important: Protect your credentials file:

mkdir -p ~/.secrets/certbot
chmod 700 ~/.secrets/certbot
chmod 600 ~/.secrets/certbot/opusdns.ini

Usage

Basic Certificate (Single Domain)

certbot certonly \
  --authenticator dns-opusdns \
  --dns-opusdns-credentials ~/.secrets/certbot/opusdns.ini \
  --dns-opusdns-propagation-seconds 60 \
  -d example.com

Wildcard Certificate

certbot certonly \
  --authenticator dns-opusdns \
  --dns-opusdns-credentials ~/.secrets/certbot/opusdns.ini \
  --dns-opusdns-propagation-seconds 60 \
  -d example.com \
  -d "*.example.com"

Multiple Domains

certbot certonly \
  --authenticator dns-opusdns \
  --dns-opusdns-credentials ~/.secrets/certbot/opusdns.ini \
  -d example.com \
  -d www.example.com \
  -d api.example.com

Sandbox/Testing Environment

For testing with OpusDNS sandbox:

# opusdns.ini
dns_opusdns_api_key = opk_sandbox_key_here
dns_opusdns_api_endpoint = https://sandbox.opusdns.com
certbot certonly \
  --authenticator dns-opusdns \
  --dns-opusdns-credentials opusdns.ini \
  --server https://acme-staging-v02.api.letsencrypt.org/directory \
  -d example.com

Docker Usage

Using docker-compose

  1. Copy example files:

    cp .env.example .env
    cp opusdns.ini.example credentials/opusdns.ini
    
  2. Edit .env and credentials/opusdns.ini with your values

  3. Run certbot:

    docker-compose up certbot
    

Manual Docker

docker run -it --rm \
  -v $(pwd)/letsencrypt:/etc/letsencrypt \
  -v $(pwd)/credentials:/credentials:ro \
  certbot-dns-opusdns \
  certonly \
  --authenticator dns-opusdns \
  --dns-opusdns-credentials /credentials/opusdns.ini \
  -d example.com

Command-Line Options

Option Description Default
--dns-opusdns-credentials Path to credentials INI file Required
--dns-opusdns-propagation-seconds Time to wait for DNS propagation 60

How It Works

  1. Zone Detection: Iterates through domain parts to find the matching OpusDNS zone via GET /v1/dns/{candidate}
  2. Record Creation: Creates _acme-challenge TXT record via PATCH /v1/dns/{zone}/records (upsert operation)
  3. DNS Propagation Polling: Polls public DNS resolvers (8.8.8.8, 1.1.1.1) to verify record propagation
  4. Validation: Let's Encrypt validates the challenge
  5. Cleanup: Removes the challenge record (best-effort, logs errors)

API Details

Authentication

  • Header: X-Api-Key: opk_...

Endpoints Used

  • GET /v1/dns/{zone} — Zone lookup for zone detection
  • PATCH /v1/dns/{zone}/records — Create/remove TXT records

Error Handling

  • 401 Unauthorized: Invalid API key
  • 404 Not Found: Zone doesn't exist in your account
  • 429 Rate Limit: Automatic retry with exponential backoff (max 3 attempts)
  • 5xx Server Error: Automatic retry with backoff

Troubleshooting

"No OpusDNS zone found for domain"

  • Ensure your domain is added to OpusDNS
  • Check that the zone name matches (e.g., example.com for www.example.com)

"Invalid API key"

  • Verify API key format: opk_{26 chars}_{30 chars}_{6 chars}
  • Check API key permissions in OpusDNS dashboard
  • Ensure no extra whitespace in credentials file

"DNS propagation timeout"

  • Increase --dns-opusdns-propagation-seconds (e.g., 120)
  • Check OpusDNS dashboard for zone status
  • Verify nameservers are correctly configured

"Rate limit exceeded"

  • OpusDNS has API rate limits
  • Plugin automatically retries with backoff
  • Reduce concurrent certificate requests

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest -v

# Run tests with coverage
pytest --cov=certbot_dns_opusdns --cov-report=html

# Lint
ruff check certbot_dns_opusdns tests

# Type check
mypy certbot_dns_opusdns

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

MIT License — See LICENSE file.

Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

certbot_dns_opusdns-1.0.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

certbot_dns_opusdns-1.0.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file certbot_dns_opusdns-1.0.0.tar.gz.

File metadata

  • Download URL: certbot_dns_opusdns-1.0.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for certbot_dns_opusdns-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f55adabec42cd8e6bf3aa401eca6dbc281c380f9c53f4b2a515ba85d5f3a8e15
MD5 65e5bd8390c8ec5cfbb4a11e4825ca79
BLAKE2b-256 c238da7788be59ca9f3da41b9d182a977c2e886c8650985f2e3434461a75456f

See more details on using hashes here.

Provenance

The following attestation bundles were made for certbot_dns_opusdns-1.0.0.tar.gz:

Publisher: release.yml on OpusDNS/certbot-dns-opusdns

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file certbot_dns_opusdns-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for certbot_dns_opusdns-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0347661ce22980c1e2f3246a9bb48f289476aa1163e2fc04f2831274af02ea00
MD5 663ac1f07b7178a7dfafbdb504a945e5
BLAKE2b-256 6c227555b0c8478e435288620f56a901a37481bfb4ff1b1110c529e6cc6821d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for certbot_dns_opusdns-1.0.0-py3-none-any.whl:

Publisher: release.yml on OpusDNS/certbot-dns-opusdns

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page