acme

package module
v1.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2025 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

acme

CoreDNS plugin for serving ACME DNS-01 TXT records via a tiny HTTP API. Stores data in-memory (ephemeral). No accounts, no multiuser features, no metrics.

What It Does

  • Answers TXT queries for names under _acme-challenge. in configured zones
  • Exposes a minimal API to add TXT values kept in memory
  • Supports multiple TXT values per FQDN (for concurrent challenges)
  • Deduplicates identical TXT values; values remain until restart
  • Falls through to the next plugin for anything else

Syntax

acme . {
    [basic_auth USER PASS]
}
  • basic_auth: Protects /present and /cleanup with HTTP Basic Auth.

API

All data is stored in-memory and lost on restart.

  • POST /present

    • Body: { "fqdn": "_acme-challenge.example.org.", "value": "<43-char-token>" }
    • Adds the TXT value for the FQDN. If the same value already exists, it is ignored. Multiple distinct values are retained concurrently.
  • POST /cleanup

    • Body: { "fqdn": "_acme-challenge.example.org.", "value": "<43-char-token>" }
    • Removes the provided TXT value for the FQDN. If the value is omitted, all TXT values for the FQDN are removed. Missing records are ignored for idempotency.
  • GET /health

    • Returns 200 OK when the API is up.

Notes:

  • fqdn is canonicalized; include the trailing dot for clarity.
  • Only ACME-safe TXT values are accepted (base64url; 43 characters).

Example

.:5335 {
 errors

 file /data/Zonefile {
   reload 30s
   fallthrough
 }
 forward . tls://9.9.9.10  {
        tls_servername dns10.quad9.net
        health_check 15s
 }
 forward . tls://1.1.1.1 tls://1.0.0.1 {
    tls_servername cloudflare-dns.com
    health_check 15s
 }

 cache 60

}
.:53 https://dns.example.com {
#    log
    errors
    acme {
        basic_auth admin passwd

        fallthrough
    }

    forward . 127.0.0.1:5335

    cache 60
}



Traefik (lego httpreq provider)
HTTPREQ_ENDPOINT=http://auth.example.org:8055

If basic_auth is configured, include credentials:

HTTPREQ_USERNAME=user
HTTPREQ_PASSWORD=pass

If not set, the API is open (no auth).

The API server always listens on HTTP :8055.

Build

Add to CoreDNS plugin.cfg:

acme:github.com/libnewton/coredns-lego

Then build CoreDNS as usual.

License

MIT

Documentation

Overview

Package acme implements a CoreDNS plugin that handles ACME DNS-01 challenges. It provides a REST API for updating TXT records needed for ACME DNS-01 validation.

Index

Constants

View Source
const TXT_LENGTH = 43

Variables

View Source
var (
	ErrRecordNotFound   = errors.New("record not found")
	ErrReadOnlyDatabase = errors.New("database is in read-only mode")
)

Functions

This section is empty.

Types

type ACME

type ACME struct {
	Next plugin.Handler
	Fall fall.F

	APIConfig APIConfig
	// Basic Auth (optional)
	BasicAuth struct {
		User string
		Pass string
	}
	// contains filtered or unexported fields
}

ACME is a CoreDNS plugin that implements the ACME DNS challenge protocol

func (*ACME) Name

func (a *ACME) Name() string

Name implements the plugin.Handler interface

func (*ACME) ServeDNS

func (a *ACME) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handler interface.

func (*ACME) Shutdown

func (a *ACME) Shutdown() error

func (*ACME) Startup

func (a *ACME) Startup() error

startAPIServer starts the HTTP API server

type ACMETxt

type ACMETxt struct {
	FQDN  string `json:"fqdn"`
	Value string `json:"value"`
}

type APIConfig

type APIConfig struct {
	// APIAddr is the address of the API server
	APIAddr string
}

APIConfig holds API server configuration

type DB

type DB interface {
	GetRecords(fqdn string) ([]string, error)
	PresentRecord(fqdn string, value string) error
	CleanupRecord(fqdn string, value string) error
	Close() error
}

DB interface for storing ACME TXT records

type MemDB

type MemDB struct {
	// contains filtered or unexported fields
}

func NewMemDB

func NewMemDB() *MemDB

func (*MemDB) CleanupRecord added in v1.13.1

func (m *MemDB) CleanupRecord(fqdn, value string) error

func (*MemDB) Close

func (m *MemDB) Close() error

func (*MemDB) GetRecords

func (m *MemDB) GetRecords(fqdn string) ([]string, error)

func (*MemDB) PresentRecord

func (m *MemDB) PresentRecord(fqdn, value string) error

PresentRecord overwrites any existing value for fqdn

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址