Skip to content

OpenPGP mailbox binding

A mailbox is bound to a primary fingerprint explicitly accepted by the operator. A matching UID alone is insufficient. This is a recipient or client policy, not a Postfix DNS setting.

Setup

Prerequisite: your values and Debian packages. Run this automation example as root; personal signing keys belong in the signing user's account. Preserve existing configuration.

First create or independently obtain the OpenPGP key. Confirm the expected full primary fingerprint through a second trusted channel. Run the following block only after that confirmation: it creates a local pin and dated public snapshot.

set -euo pipefail
. /root/mailserver.env
export GNUPGHOME=/root/mail-pgp
install -d -m 0700 /root/mail-pins
FPR=$(gpg --with-colons --fingerprint "$MAILBOX" | awk -F: '$1=="fpr" {print $10; exit}')
test "${#FPR}" -eq 40
printf '%s\n' "$FPR"
# Independently confirm the displayed fingerprint first.
printf '%s\n' "$FPR" > /root/mail-pins/expected-primary.txt
gpg --armor --export "$FPR" > /root/mail-pins/public.asc
sha256sum /root/mail-pins/public.asc > /root/mail-pins/snapshot.sha256
date +%s > /root/mail-pins/observed-at
printf '%s\n' "$MAILBOX" > /root/mail-pins/mailbox.txt

The snapshot freshness limit here is 24 hours. Update its date only after actually obtaining a new snapshot from the explicitly accepted source. A timer that merely changes the date does not prove freshness. Do not automatically accept an unknown replacement key.

Test

set -euo pipefail
. /root/mailserver.env
sha256sum -c /root/mail-pins/snapshot.sha256
observed=$(cat /root/mail-pins/observed-at)
age=$(( $(date +%s) - observed ))
test "$age" -ge 0 && test "$age" -le 86400
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
chmod 0700 "$tmp"
gpg --homedir "$tmp" --batch --import /root/mail-pins/public.asc
actual=$(gpg --homedir "$tmp" --with-colons --fingerprint "$MAILBOX" | awk -F: '$1=="fpr" {print $10; exit}')
test "$actual" = "$(cat /root/mail-pins/expected-primary.txt)"
test "$MAILBOX" = "$(cat /root/mail-pins/mailbox.txt)"
gpg --homedir "$tmp" --status-fd 1 --verify /root/mail-pgp/message.txt.asc /root/mail-pgp/message.txt > "$tmp/status"
grep -F "[GNUPG:] VALIDSIG " "$tmp/status" | grep -F "$actual"
if grep -E '\[GNUPG:\] (REVKEYSIG|EXPKEYSIG|EXPSIG|BADSIG)' "$tmp/status"; then exit 1; fi
echo 'PASS: snapshot, freshness, explicit pin and signature checks succeeded.'

Cryptographic verification does not replace independent pin confirmation. Revocation information is limited to the public snapshot you obtained; it does not establish global absence of revocation. Also test PGP/MIME in the actual client.