OpenPGP¶
OpenPGP signing happens in the sender's application or mailclient. It does not make Postfix add a PGP/MIME signature. Recipients need the public key and their own trust decision.
The OpenPGP card shows the recorded cryptographic signature validity. OpenPGP mailbox binding separately assesses whether the operator policy binds the key to the sender address. An unconfirmed personal identity does not turn either successful check into an unknown result. A missing signature does not receive a positive verdict.
Setup¶
Prerequisite: your values and Debian packages. This automation example runs as root; personal keys belong in the signing user's account. Merge changes on existing servers.
set -euo pipefail
. /root/mailserver.env
install -d -m 0700 /root/mail-pgp
export GNUPGHOME=/root/mail-pgp
if ! gpg --list-keys "$MAILBOX" >/dev/null 2>&1; then
umask 077
openssl rand -base64 32 > /root/mail-pgp/passphrase
gpg --batch --pinentry-mode loopback --passphrase-file /root/mail-pgp/passphrase \
--quick-generate-key "$MAILBOX" rsa3072 cert,sign 1y
fi
gpg --with-colons --fingerprint "$MAILBOX"
gpg --armor --export "$MAILBOX" > /root/mail-pgp/public.asc
printf 'OpenPGP functional test\n' > /root/mail-pgp/message.txt
gpg --batch --yes --pinentry-mode loopback --passphrase-file /root/mail-pgp/passphrase \
--armor --detach-sign --output /root/mail-pgp/message.txt.asc /root/mail-pgp/message.txt
This block creates a new automation key and a random passphrase in a root-only file. Storing key and passphrase on the same host does not protect against compromise of the entire account. For a personal mailclient, use its own user account and choose a passphrase interactively with gpg --quick-generate-key; preserve existing keys. Independently confirm the full primary fingerprint and import the public key into the client. Select PGP/MIME. Back up the private key, passphrase and revocation certificate offline; never publish them.
Test¶
set -euo pipefail
export GNUPGHOME=/root/mail-pgp
gpg --verify /root/mail-pgp/message.txt.asc /root/mail-pgp/message.txt
cp /root/mail-pgp/message.txt /root/mail-pgp/changed.txt
printf 'modified\n' >> /root/mail-pgp/changed.txt
if gpg --verify /root/mail-pgp/message.txt.asc /root/mail-pgp/changed.txt; then
echo 'ERROR: modified content accepted' >&2
exit 1
fi
echo 'PASS: original content valid; modified content invalid.'
This CLI test verifies a detached OpenPGP signature. Also send a PGP/MIME message with your actual mailclient and verify it at the recipient. A valid signature or matching UID does not automatically establish mailbox binding or personal identity.