STARTTLS Makes The Internet Better

March 2014: STARTTLS in OpenSMTPd
Introduction
So, let’s spend a minute enabling TLS in OpenSMTPd on OpenBSD. We’ll have to generate certificates and then tell smtpd.conf about that certificate.
Links
Things you see
Things you type
Bonus: Turn on Encrypted Queues at the end of this document.
Make some certificates
You’re here instead of reading the man pages. Cool...find specific info quickly, I get it, but check them out sometime.
man smtpd.conf
man starttls
Let’s get started by creating a keypair in the default directory.
export CERTFILENAME=alix2d13
mkdir -p /etc/mail/certs
# cron this up
openssl dsaparam 1024 -out dh1024.pem
openssl dsaparam 2048 -out dh2048.pem                                                                                        
# make a ten year certificate
openssl genrsa -out /etc/mail/certs/${CERTFILENAME}.key 4096
openssl req -sha512 -new -x509 -key /etc/mail/certs/${CERTFILENAME}.key \
     -out /etc/mail/certs/${CERTFILENAME}.crt -days 3658
# i had to remove this and use automatic DH
ln dh2048.pem ${CERTFILENAME}.dh
Update /etc/mail/smtpd.conf
Old configuration
listen on lo0
New Configuration
pki alix2d13 certificate "/etc/mail/certs/alix2d13.crt" key "/etc/mail/certs/alix2d13.key" listen on lo0 tls certificate "alix2d13"
If your mailserver is already configured for STARTTLS, it should pick up the changes:
/etc/rc.d/smtpd restart # or, smtpd -dv
openssl s_client -connect localhost:25 -starttls smtp
Bonus: Encrypted Queues
Just because it exists, you can turn on queue encryption quickly.
cryptokey=`openssl rand -hex 16`
echo "queue encryption key ${cryptokey}" >> /etc/mail/smtpd.conf                                                                                                             
The end.
Copyright © 2014 Patrick Tudor