Skip to content

About

signing-milter enables you to s/mime sign an ordinary mail while passing a MTA. Base on https://signing-milter.org/ by Andreas Schulze

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

signing-milter in systemd

signing-milter enables you to s/mime sign an ordinary mail while passing a MTA. It is written in C and tested with the postfix MTA. It should work with any MTA implementing the milter protocol.

This repository replaces the daemontools service manager used in the original release by the Debian standard systemd service.

Debian/Ubuntu Repository

Currently supported debian/ubuntu versions:

  • buster
  • bullseye
  • bookworm
  • trixie
  • focal
  • jammy
  • noble
  • resolute

How to add this repository:

Automatically via script

wget -O- https://smeinecke.github.io/signing-milter/scripts/add-repository.sh | bash
apt-get install signing-milter

Manually

Legacy one-line source

For releases still using the traditional one-line sources.list format (Debian buster/bullseye/bookworm, Ubuntu focal/jammy):

apt-get install wget lsb-release ca-certificates
wget -O /usr/share/keyrings/smeinecke.github.io-signing-milter.key https://smeinecke.github.io/signing-milter/public.key
echo "deb [signed-by=/usr/share/keyrings/smeinecke.github.io-signing-milter.key] https://smeinecke.github.io/signing-milter/repo $(lsb_release -sc) main" > /etc/apt/sources.list.d/signing-milter.list
apt-get update && apt-get install signing-milter
DEB822 source

For releases using the new DEB822 .sources format (Debian trixie, Ubuntu noble/resolute):

apt-get install wget lsb-release ca-certificates
wget -O /usr/share/keyrings/smeinecke.github.io-signing-milter.key https://smeinecke.github.io/signing-milter/public.key
cat > /etc/apt/sources.list.d/signing-milter.sources <<EOF
Types: deb
URIs: https://smeinecke.github.io/signing-milter/repo
Suites: $(lsb_release -sc)
Components: main
Signed-By: /usr/share/keyrings/smeinecke.github.io-signing-milter.key
EOF
apt-get update && apt-get install signing-milter

Build from source

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make

Optional dmalloc support:

cmake -DENABLE_DMALLOC=ON -DCMAKE_BUILD_TYPE=Release ..
make

To build a Debian package:

dpkg-buildpackage -us -uc -b

Optional Redis certificate backend

If signing-milter is built with WITH_REDIS=ON (the default), it can fetch S/MIME certificates and private keys from a Redis server instead of, or in addition to, the local CDB signingtable.

The Redis key for an address is built from the configured prefix and the lowercased address (e.g. signing-milter:sender@example.com). The hash must contain the following fields:

  • pem (required): a PEM blob containing both the signer certificate and the corresponding private key.
  • chain (optional): a PEM blob with the intermediate/root certificate chain.

Example Redis HMSET:

redis-cli HMSET signing-milter:sender@example.com \
    pem "$(cat /path/to/sender-cert+key.pem)" \
    chain "$(cat /path/to/sender-chain.pem)"

To enable the Redis backend, add -r, optionally -P and -W, to /etc/default/signing-milter:

OPTIONS="-s unix:/var/spool/postfix/signing-milter/signing-milter.sock -c postfix -r redis://127.0.0.1:6379/0 -P signing-milter: -W /etc/signing-milter/passphrase"

The passphrase file is used for encrypted private keys loaded from Redis. When Redis is enabled, the milter queries Redis first; on a miss it falls back to the local CDB signingtable.

Build from source with or without Redis

By default CMake searches for libhiredis and enables Redis support:

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j"$(nproc)"

To build without Redis support (no libhiredis dependency):

cmake -B build -DCMAKE_BUILD_TYPE=Release -DWITH_REDIS=OFF
cmake --build build -j"$(nproc)"

Run the Docker integration tests

The full test suite including the Redis end-to-end test can be run with Docker Compose:

docker compose -f tests/docker-compose.yml up --build --abort-on-container-exit

Basic postfix configuration

In default configuration the postfix daemon is chrooted to the spool folder located in /var/spool/postfix/. To use the socket feature of signing-milter the socket + permissions has to be configured in the /etc/default/signing-milter file:

#DISABLE_HOURLY_STATISTICS_LOGGING='yes'
#DISABLE_DAILY_STATISTICS_LOGGING='yes'
OPTIONS="-s unix:/var/spool/postfix/signing-milter/signing-milter.sock -c postfix"

Also create the folder within the postfix spool folder with the correct permissions:

mkdir -m o-rwx /var/spool/postfix/signing-milter
chown signing-milter:postfix /var/spool/postfix/signing-milter

The socket has to be configured in postfix in main.cf as new milter:

smtpd_milters = unix:signing-milter/signing-milter.sock

And reload/restart the services:

systemctl restart signing-milter
systemctl reload postfix

Configure certificates

All certificates are configured in the /etc/signing-milter/signingtable file.

Just add the email address + path of the pem file and use

cd /etc/signing-milter && make

to update the cdb database and trigger reloading signing-milter.

The certificates have to be readable by the signing-milter user.

Intermediate certificates

Since version 20120731 signing-milter also supports intermediate certificates.

Just name your certificate with the suffix -cert+key.pem and put the intermediate + root certificate in a file suffixed by -chain.pem in the same folder.

Contributing

The project is based on signing-milter.org by Andreas Schulze.

Thanks to Rouven Spreckels for the statistics logging fix in PR #9.

About

signing-milter enables you to s/mime sign an ordinary mail while passing a MTA. Base on https://signing-milter.org/ by Andreas Schulze

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages