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

Publishes a verified current archive and optional dated backup. More...

Functions

int certbotbot_s3_publish (String workspace, String selected, String bucket, String key, String changed, String override)
 Publishes the full validated candidate to current, then optional dated S3 key.
 

Detailed Description

Publishes a verified current archive and optional dated backup.

Implements ADR-028's current-key no-op policy and ADR-033's optional same-payload dated copy. The default remains one authoritative object. This module is a post-success execution adapter. It requires an already successful selected Certbot operation and its independently verified durable-change result from the caller. It never calls Certbot, restores cloud resources, selects an ACME account, or infers a fallback S3 object.

Before PutObject it requires private canonical state and invokes the existing candidate archive builder itself. No arbitrary provided file may bypass validation. Certificate renewal and durable-state changes are distinct: changed=true requires publication even if Certbot issued no new leaf. When changed=false, a successful unchanged no-op publishes only if the explicit override is true. The normative product truth table is in doc/mvp-upload-no-renewal-policy.md. AWS CLI v2 is inherited from the operator's environment; command output is suppressed. Failed PutObject leaves remote state unknown, not necessarily unchanged. The caller owns cleanup and externally serialized S3 writers. Mocked before/after remote digest and lost-response tests are specified in doc/mvp-failure-preservation.md.

Function Documentation

◆ certbotbot_s3_publish()

int certbotbot_s3_publish ( String  workspace,
String  selected,
String  bucket,
String  key,
String  changed,
String  override 
)

Publishes the full validated candidate to current, then optional dated S3 key.

WORKSPACE/config must contain a complete, already processed selected lineage, a single registered production account, and canonical renewal metadata for every stored lineage. The full candidate includes every unrelated lineage, not a selected-only subset. The caller must have verified the Certbot result and certificate material, and must pass the exact bucket/key used for the earlier S3 read.

When CHANGED and OVERRIDE are both false, no candidate or AWS call is performed; CERTBOTBOT_S3_PUBLISHED=false indicates a successful skip. Otherwise the function creates WORKSPACE/candidate.tar.gz through certbotbot_archive_package, which enforces strict tar/gzip validation. When ADR-031 encryption is enabled, only a validated authenticated OCB
## envelope is eligible for the single same-key PutObject call. Migration
## forces one verified publication even for otherwise unchanged Certbot state.
## It sends the chosen file using one AWS CLI v2 s3api put-object call with explicit SHA256 checksum algorithm and application/gzip content type. On successful current PUT CERTBOTBOT_S3_PUBLISHED=true. A failed backup after accepted current PUT is reported as a distinct nonzero partial success, without a speculative rollback. The same exact validated candidate bytes are used for current and backup; there is no independent re-encryption.

The status says whether this local invocation requested and received success from AWS, not whether a later independent read will succeed. S3 concurrent writes and partial/interrupted publication are outside this module's guarantees. The private candidate remains for the workspace owner to remove.

Parameters
workspaceCanonical private, owned mode-0700 invocation workspace.
selectedValidated selected non-wildcard certificate lineage name.
bucketThe same configured existing S3 bucket used for retrieval.
keyThe same configured object key used for retrieval.
changedLiteral true/false verified durable-state change result.
overrideLiteral true/false UPLOAD_NO_RENEWAL configuration value.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Static non-sensitive errors, no AWS credentials or service output.
Returns
Nothing is written to STDOUT.
Return values
0Upload was accepted, or a verified unchanged no-op was skipped.
64Invalid arguments, bucket/key or private workspace.
65Restored selected account/lineage or metadata is unsuitable.
69AWS CLI unavailable.
74Candidate or current PutObject failed, or current was accepted but the optional backup PutObject/confirmation failed.
Note
Candidate builder may also propagate its defined 64 or 65 statuses.
Examples
certbotbot_s3_publish "$workspace" "$CERTBOTBOT_CERT_NAME" \
"$CERTBOTBOT_S3_BUCKET" "$CERTBOTBOT_S3_KEY" \
"$CERTBOTBOT_DURABLE_CHANGED" "$CERTBOTBOT_UPLOAD_NO_RENEWAL" ||
exit $?
int certbotbot_s3_publish(String workspace, String selected, String bucket, String key, String changed, String override)
Publishes the full validated candidate to current, then optional dated S3 key.