certbotbot
Reference documentation for a modular Bash project
Loading...
Searching...
No Matches
Functions | Variables
state.bash File Reference

Verifies local ACME account presence and selected-lineage coherence. More...

Functions

int certbotbot_ca_select ()
 Binds the ordinary issuer to exactly one supported Let's Encrypt CA.
 
int certbotbot_state_account (String config)
 Requires one unambiguous account for the selected ACME environment.
 
int certbotbot_state_hooks (String config)
 Rejects archived hook configuration and executable hook directories.
 
int certbotbot_state_lineage_one (String config, String name)
 Verifies one complete lineage's relative links and local member types.
 
int certbotbot_state_lineage (String config, String selected)
 Inventories every valid lineage and classifies one selected target.
 
int certbotbot_state_inventory (String config, String selected)
 Inventories and canonically validates every archived lineage.
 
int certbotbot_state_canonical_all (String config, String selected)
 Verifies canonical renewal metadata for every stored certificate.
 
int certbotbot_state_unselected_fingerprint (String config, String selected)
 Hashes unchanged lineage payloads outside the selected namespace.
 
int certbotbot_state_preflight (String config, String selected)
 Verifies restored account and selected lineage without side effects.
 

Variables

IndexedArray CERTBOTBOT_ARCHIVED_NAMES
 Sorted exact identities from the validated restored archive.
 

Detailed Description

Verifies local ACME account presence and selected-lineage coherence.

This module enforces the read-only preflight contract in ADR-023. Archive format verification and safe extraction must already have completed. No restored scripts or configuration are executed or sourced. The checks deliberately do not claim that the account is registered remotely or that canonical renewal metadata has been mapped into a private Certbot runtime.

Function Documentation

◆ certbotbot_ca_select()

int certbotbot_ca_select ( )

Binds the ordinary issuer to exactly one supported Let's Encrypt CA.

ADR-042 permits an explicit staging selection and retains production as the compatibility default. The selected host and server are derived only from the bounded environment, never from untrusted archive content.

STDOUT
Nothing is written to STDOUT.
STDERR
One fixed diagnostic when the environment is unsupported.
Return values
0Selected host and server are bound.
64Invalid CA environment.

◆ certbotbot_state_account()

int certbotbot_state_account ( String  config)

Requires one unambiguous account for the selected ACME environment.

The account must occupy the explicitly selected CA directory and contain nonempty, regular registration, key and metadata files. No other account endpoints or competing IDs are allowed in the single-account MVP. The key must have no group/other permissions. Content is never printed or parsed.

Parameters
configCanonical private restored Certbot configuration root.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Nothing is written to STDERR.
Returns
Nothing is written to STDOUT.
Return values
0One local account has the required expected structure.
1Account selection or on-disk structure is unsuitable.

◆ certbotbot_state_canonical_all()

int certbotbot_state_canonical_all ( String  config,
String  selected 
)

Verifies canonical renewal metadata for every stored certificate.

The selected name is an operation target, not a filter for state safety. Before provider execution and before publication, verify all persisted renewal files against the selected CA account/Route53 dialect. This function must only run when renewal paths are canonical: never between selected prepare/finalize operations. The read-only mapper uses ordinary structural preflight and does not rewrite any renewal file in verify mode.

Parameters
configCanonical owned restored configuration directory.
selectedExact validated current selected lineage name.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Fixed non-secret diagnostics only.
Return values
0Every archived lineage has canonical supported metadata.
65Any incomplete or noncanonical archive state.

◆ certbotbot_state_hooks()

int certbotbot_state_hooks ( String  config)

Rejects archived hook configuration and executable hook directories.

Archived hook command execution is excluded from the MVP. A cli.ini file can inject arbitrary Certbot options and is therefore refused. Empty renewal-hooks directories may exist, but no non-directory members are allowed. A later version may add reviewed compatibility for specific inert options; this version fails closed.

Parameters
configCanonical private restored configuration root.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Nothing is written to STDERR.
Returns
Nothing is written to STDOUT.
Return values
0No disallowed global hook options or scripts were found.
1Unexpected hook content or unsafe configuration was found.

◆ certbotbot_state_inventory()

int certbotbot_state_inventory ( String  config,
String  selected 
)

Inventories and canonically validates every archived lineage.

Derives case-sensitive names from regular renewal configuration members, then requires the existing full account, hook, triplet and canonical renewal-metadata preflight to accept the whole workspace. The selected identity is an optional already-validated target; when omitted, the first archived identity is used only as a read-only preflight reference. No synthetic certificate identity is created. An account-only archive is supported only with an explicit selected identity for issuance. Runs in C locale to produce a deterministic lexical order independent of runner configuration; no raw archive material is emitted.

Parameters
configPrivate restored mode-0700 Certbot configuration root.
selectedExact ordinary selected name or empty for domainless bulk.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Fixed nonsecret diagnostics on invalid restored state.
Returns
Validated names in CERTBOTBOT_ARCHIVED_NAMES.
Return values
0All archived identities and account metadata are valid.
64Invalid selected identity or configuration root.
65Malformed state or zero lineages in domainless bulk mode.
Note
Preflight or canonical checks may propagate their own nonzero status.
Examples
certbotbot_state_inventory "$workspace/config" "" || return $?
for name in "${CERTBOTBOT_ARCHIVED_NAMES[@]}"; do
: "Do not infer renewal authority from name enumeration alone"
done
int certbotbot_state_inventory(String config, String selected)
Inventories and canonically validates every archived lineage.

◆ certbotbot_state_lineage()

int certbotbot_state_lineage ( String  config,
String  selected 
)

Inventories every valid lineage and classifies one selected target.

An account-only archive may omit all lineage trees. All non-README members in renewal/, live/ and archive/ must have complete matching triplets. Every name is validated separately, so an unrelated existing certificate cannot be silently dropped or chosen by SAN overlap. This read-only check validates the local structure of every stored lineage and reports whether the exact selected lineage is present or absent; canonical renewal metadata is separately verified using certbotbot_state_canonical_all.

Parameters
configPrivate restored configuration root.
selectedValidated non-wildcard certificate name.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Nothing is written to STDERR.
Returns
Nothing is written to STDOUT; selected status is stored in REPLY.
Return values
0Every stored lineage is complete; selected is absent or present.
1Unsupported, ambiguous or partial stored lineage inventory.

◆ certbotbot_state_lineage_one()

int certbotbot_state_lineage_one ( String  config,
String  name 
)

Verifies one complete lineage's relative links and local member types.

The caller has inventoried all top-level renewal/live/archive names. This read-only check never uses contents of archived renewal configuration as shell code. Every live link must target its own matching archive subtree, not another certificate's versioned PEM or an absolute path.

Parameters
configPrivate restored configuration root.
nameValidated non-wildcard Certbot lineage name.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Nothing is written to STDERR.
Return values
0Complete and safe supported lineage structure.
1Partial or unsafe files, links, hooks or member types.

◆ certbotbot_state_preflight()

int certbotbot_state_preflight ( String  config,
String  selected 
)

Verifies restored account and selected lineage without side effects.

This function is valid only after a private archive restoration. It checks canonical ownership/privacy, a single recognized ACME account, absence of archived hook execution, and one coherent selected lineage. Result is set in CERTBOTBOT_LINEAGE_STATE and cleared on all failures. It never invokes Certbot/AWS, reads the host account, or writes to S3.

Parameters
configAbsolute canonical path of the private restored config root.
selectedValidated non-wildcard certificate name.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
One fixed safe diagnostic on failure.
Returns
Nothing is written to STDOUT.
Return values
0Local account structure and selected lineage are unambiguous.
64Invalid caller path or certificate name.
65Local restored state is missing, ambiguous, or unsafe.
Examples
certbotbot_state_preflight "$workspace/config" "$CERTBOTBOT_CERT_NAME" ||
exit $?
# Certbot must still verify the account and canonical path mapping.
int certbotbot_state_preflight(String config, String selected)
Verifies restored account and selected lineage without side effects.

◆ certbotbot_state_unselected_fingerprint()

int certbotbot_state_unselected_fingerprint ( String  config,
String  selected 
)

Hashes unchanged lineage payloads outside the selected namespace.

Includes all other lineages' renewal configs, versioned PEMs, private-key permissions and live symlink targets. A normalized tar stream is hashed without writing or logging certificate or account material. This digest detects unintended changes to unselected state across a selected provider call; it is not a lock or cryptographic proof of remote S3 atomicity.

Parameters
configRestored private Certbot configuration tree.
selectedSelected lineage name to exclude from this digest.
STDIN
Nothing is read from STDIN.
STDOUT
One SHA-256 digest, with no certificate or account material.
STDERR
Nothing is written to STDERR.
Returns
A fingerprint of all unselected stored lineage data.
Return values
0Stable digest calculated for complete archive inventory.
1Tooling or state inspection unavailable.

Variable Documentation

◆ CERTBOTBOT_ARCHIVED_NAMES

CERTBOTBOT_ARCHIVED_NAMES

Sorted exact identities from the validated restored archive.

This transient array is only used by explicit ADR-058 bulk maintenance. Names come from complete renewal/live/archive triplets; the ordinary selected-only lifecycle does not use it.

Bash variable: read-write indexed_array