Skip to main content

DnsProvider

Trait DnsProvider 

Source
pub trait DnsProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn publish_txt(&self, host: &str, value: &str) -> Result<(), DnsError>;
    fn withdraw_txt(&self, host: &str, value: &str) -> Result<(), DnsError>;
    fn txt_values(&self, host: &str) -> Vec<String>;
    fn publish_caa(
        &self,
        host: &str,
        values: &[CaaValue],
    ) -> Result<(), DnsError>;
    fn caa_values(&self, host: &str) -> Vec<CaaValue>;
}
Expand description

A zone the records a certificate depends on can be written into.

Implementations must be safe to share: the certificate manager holds one behind a shared reference for the life of the process and calls it from whatever task a renewal runs on.

Required Methods§

Source

fn name(&self) -> &str

Short stable identifier for this provider, used in log fields.

Source

fn publish_txt(&self, host: &str, value: &str) -> Result<(), DnsError>

Adds value to the set of TXT values published at host, leaving any other values at that name untouched.

A TXT name used for the ACME DNS-01 challenge holds a set: issuing one certificate that covers both pds.example and *.pds.example requires two simultaneous values at _acme-challenge.pds.example, one per name being validated, and a provider that cannot hold both cannot issue that certificate. Calling this twice with the same value is a no-op, not a collision: a retried challenge publish must not fail.

Returns once the value is visible to a resolver, on a backend that can tell: the caller’s next step is to ask the authority to look.

Source

fn withdraw_txt(&self, host: &str, value: &str) -> Result<(), DnsError>

Removes one TXT value at host, leaving any other values at that name untouched.

Removing the last value at a name removes the name; removing a value that was never published, or a value that has already been withdrawn, fails with DnsError::NotPublished.

Source

fn txt_values(&self, host: &str) -> Vec<String>

Every TXT value currently published at host, sorted.

Empty, not an error, when nothing is published there — checking is a read, and an empty set is a legitimate answer to it. Sorted so that a test or an operator comparing two listings sees a difference only when the set actually differs.

Source

fn publish_caa(&self, host: &str, values: &[CaaValue]) -> Result<(), DnsError>

Replaces the CAA record set at host with exactly values, removing the record entirely when values is empty.

An upsert, deliberately not DnsProvider::publish_txt’s additive rule. Adding to a CAA set widens who may issue; the operation this needs is “authorise these and nobody else”, which only a replacement gives. A zone’s issuance policy is one statement with one writer, restated on every start from the account and authority the process is actually about to order through; a provider that refused to restate it could never correct a stale one, and a stale CAA naming an account this deployment no longer holds is an outage on the next renewal rather than a safe default.

CAA lives at the zone apex, beside the address record for the server itself. The two do not collide: they are different record types at one name rather than two answers to one question.

Source

fn caa_values(&self, host: &str) -> Vec<CaaValue>

Every CAA value currently published at host, sorted.

Empty, not an error, when nothing is published there — the same reasoning DnsProvider::txt_values documents.

Trait Implementations§

Source§

impl DnsProvider for Box<dyn DnsProvider>

A boxed provider is a provider.

A caller that picks its backend at runtime needs one concrete type every arm produces. Box<dyn DnsProvider> is that type, and this impl is what lets it stand in for a generic parameter instead of the caller writing an enum with one variant per backend.

Source§

fn name(&self) -> &str

Short stable identifier for this provider, used in log fields.
Source§

fn publish_txt(&self, host: &str, value: &str) -> Result<(), DnsError>

Adds value to the set of TXT values published at host, leaving any other values at that name untouched. Read more
Source§

fn withdraw_txt(&self, host: &str, value: &str) -> Result<(), DnsError>

Removes one TXT value at host, leaving any other values at that name untouched. Read more
Source§

fn txt_values(&self, host: &str) -> Vec<String>

Every TXT value currently published at host, sorted. Read more
Source§

fn publish_caa(&self, host: &str, values: &[CaaValue]) -> Result<(), DnsError>

Replaces the CAA record set at host with exactly values, removing the record entirely when values is empty. Read more
Source§

fn caa_values(&self, host: &str) -> Vec<CaaValue>

Every CAA value currently published at host, sorted. Read more

Implementations on Foreign Types§

Source§

impl DnsProvider for Box<dyn DnsProvider>

A boxed provider is a provider.

A caller that picks its backend at runtime needs one concrete type every arm produces. Box<dyn DnsProvider> is that type, and this impl is what lets it stand in for a generic parameter instead of the caller writing an enum with one variant per backend.

Source§

fn name(&self) -> &str

Source§

fn publish_txt(&self, host: &str, value: &str) -> Result<(), DnsError>

Source§

fn withdraw_txt(&self, host: &str, value: &str) -> Result<(), DnsError>

Source§

fn txt_values(&self, host: &str) -> Vec<String>

Source§

fn publish_caa(&self, host: &str, values: &[CaaValue]) -> Result<(), DnsError>

Source§

fn caa_values(&self, host: &str) -> Vec<CaaValue>

Source§

impl<T: DnsProvider + ?Sized> DnsProvider for Arc<T>

A shared provider is a provider.

One provider instance, held in more than one place at once: the certificate manager for a zone and a test that inspects what it wrote look at the same maps. Box<dyn DnsProvider> cannot be shared, so this is the form that case takes. Generic over T rather than written for Arc<dyn DnsProvider> alone, so that a caller keeping a concrete provider can hand the same Arc to something that wants only the trait.

Source§

fn name(&self) -> &str

Source§

fn publish_txt(&self, host: &str, value: &str) -> Result<(), DnsError>

Source§

fn withdraw_txt(&self, host: &str, value: &str) -> Result<(), DnsError>

Source§

fn txt_values(&self, host: &str) -> Vec<String>

Source§

fn publish_caa(&self, host: &str, values: &[CaaValue]) -> Result<(), DnsError>

Source§

fn caa_values(&self, host: &str) -> Vec<CaaValue>

Implementors§