DKIM |
Server - Postfix |
DKIM Domainkeys uses a system to verify the DNS domain of the email sender and therefore confirm email integrity. This is an older type of verification. DKIM is more advanced and uses a public key to sign email so that the recipient can verify the sender. The recipient must be able to access the public key using DNS. Yahoo and Gmail both use this technology. This is an example on connecting Postfix to dkimproxy.out for signing outbound messages. Messages that trigger the filter get sent to port 10027 where dkimproxy.out is listening. Dkimproxy.out processes the message and forwards the connection back to Postfix on port 10028. In order to set these ports up you must modify master.cf, make a backup of the original first.
master.cf
# want a number higher than 4. # Note: the smtp_discard_ehlo_keywords option requires Postfix 2.2 or # better. Leave it off if your version does not support it. # dksign unix - - n - 4 smtp -o smtp_send_xforward_command=yes -o smtp_discard_ehlo_keywords=8bitmime,starttls # # service for accepting messages FROM the DKIM signing proxy # 127.0.0.1:10028 inet n - n - 10 smtpd -o content_filter= -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks -o smtpd_helo_restrictions= -o smtpd_client_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks=127.0.0.0/8 -o smtpd_authorized_xforward_hosts=127.0.0.0/8 Add this line under the pickup line. Make sure to leave space before the “-o”
Install Pre-requisites and Build dkimproxy
yum install -y make yum install -y perl-Digest-SHA perl-Mail-Address perl-MIME-Base64-Perl perl-Net-DNS perl-Net-Server perl-Crypt-OpenSSL-RSA perl-Error
cd /usr/local/src
cp sample-dkim-init-script.sh /etc/init.d/dkimproxy chmod 755 /etc/init.d/dkimproxy groupadd -g 1003 dkim useradd -u 1003 -s /bin/false -d /dev/null -g dkim dkim Generate a private/public key pair using OpenSSL
Now you will have two keys, a public and private.
chown dkim:dkim *.key chmod 440 private.key Create a DNS entry for Each Domain
Use a selector name like selector1.
The first thing you will need to do is copy the example config for outgoing mail to a dkimproxy_out.conf. cp /usr/local/dkimproxy/etc/dkimproxy_out.conf.example /usr/local/dkimproxy/etc/dkimproxy_out.conf
Now edit /usr/local/dkimproxy/etc/dkimproxy_out.conf. Be sure that you have the complete path to your private key and the name of the key is exactly what you entered. The other point to be careful with is the selector. Here the standard selector1 is used, this must match what you enter in the DNS server text file.
# specify location of the private key keyfile /etc/postfix/ssl/domainkeys/private.key # specify the selector (i.e. the name of the key record put in DNS) selector selector1 # control how many processes DKIMproxy uses # - more information on these options (and others) can be found by # running `perldoc Net::Server::PreFork'. #min_servers 5 #min_spare_servers 2
Create a file which tells dkimproxy which domains have keys. Each domain must be listed separately on a line followed by the domainkeys encryption and the dkim encryption methods.
Prepare to start your dkimproxy by restarting postifix first.
Test Email Here is a link to a site where you can send an email to an address you create and it will provide output to verify your implementation of dkimproxy. http://www.brandonchecketts.com/emailtest.php
Errors May 22 12:48:53 mail dkimproxy.out[16603]: signing error: Can't call method "use_no_padding" on an undefined value at /usr/lib/perl5/vendor_perl/5.8.8/Mail/DKIM/PrivateKey.pm line 179, <FILE> line 2.
Cannot find or use private key. Restart Postfix and see error messages.
You should see that the process for dkim is running.
Example Accepted by Google
h=date:from:to:subject:message-id:mime-version:content-type; s= selector1; bh=/edzoYuyn17WXm8KeqcX/R+khdQ=; b=TV1j4gFI+yG3tIJxN1 OpW6WjO9x50T1MLkgVy8uSijfeDLJe1sp6A9RS2LmGRIQYMi7ox0RWpb9Xq3DsRT gvH88Lwcj3Ulek0Tjsj0Lwf5VwKqSLo/AdIYTJLlLU1VH22GyserpfdFb0jH37OK 4XZ2WSda60cofUB+fvLZTdCH4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=example.com; h= date:from:to:subject:message-id:mime-version:content-type; q= dns; s=selector1; b=Bv/sGggTpDLSXhrrARRSTiarXoJYXBYd1SWWzNA8AfFc PyF4HyaGtnUsFo5rdRtv7kNL+0kuJk6btWSdm2OjCandGSyyUXWZsE/qQpD/dZRH a1BukDA6QaUMw9D/TBiS54aPNxGCWWP3Se31uH0L9gUcAD/9o7FekrrNa8VrKh4=
|