M
mian
Guest
This small HOWTO will allow you to sign outgoing messages with DomainKeys http://antispam.yahoo.com/domainkeys. It is useful if you are using art's qmail-scanner RPM which modifies the qmail process to go from qmail-queue -> qmail-scanner.pl -> qmail-queue.orig to qmail-queue -> qmail-scanner.pl -> qmail-dk -> qmail-queue.orig. You can enable DomainKey verification with another option such as SpamAssassin.
One thing is Plesk does not allow you to enter hostnames with an underscore in them, to get around this you can just enter 'domainkey' without the underscore then manually update the dns_recs table to make it '_domainkey'
Download libdomainkeys from http://sourceforge.net/projects/domainkeys/
Download qmail-dk-patch from http://www.qmail.org/qmail-1.03-dk-0.53.patch
Download qmail source from ftp://ftp.jp.qmail.org/qmail/qmail-1.03.tar.gz
Compile libdomainkeys
Generate DomainKey
Untar qmail to libdomainkeys directory, patch and compile
Patch qmail-scanner-queue.pl to sign messages
Send a message to yourself and check the qmail-queue.log
If you view the message source in Thunderbird you should see the DomainKey record
You can also verify your DNS records using
http://domainkeys.sourceforge.net/policycheck.html
http://domainkeys.sourceforge.net/selectorcheck.html
One thing is Plesk does not allow you to enter hostnames with an underscore in them, to get around this you can just enter 'domainkey' without the underscore then manually update the dns_recs table to make it '_domainkey'
Download libdomainkeys from http://sourceforge.net/projects/domainkeys/
Download qmail-dk-patch from http://www.qmail.org/qmail-1.03-dk-0.53.patch
Download qmail source from ftp://ftp.jp.qmail.org/qmail/qmail-1.03.tar.gz
Compile libdomainkeys
Code:
tar -zxvf libdomainkeys-0.67.tar.gz
cd libdomainkeys-0.67
make
Generate DomainKey
Code:
./dknewkey default
# add this record to your Plesk domain template so all domains get it
default._domainkey IN TXT "k=rsa; p=MEwwDQYJKoZIhvvbfdgvfdBQADOwAwOAIxALoXn7ejsFvfIkdRo6UxmmW2BXbCOuRGc42XxDDrKHQKVMnAc0vEztfngdfgdAB"
mkdir /etc/domainkeys
cp default /etc/domainkeys
chown qmailq:qmail /etc/domainkeys/default
chmod 400 /etc/domainkeys/default
-r-------- 1 qmailq qmail 400 Aug 26 17:11 /etc/domainkeys/default
Untar qmail to libdomainkeys directory, patch and compile
Code:
tar -zxvf ../qmail-1.03.tar.gz
cd qmail-1.03
patch -p0 < ../../qmail-1.03-dk-0.53.patch
make qmail-dk
# if you receive an error regarding errno edit error.h and add #include "errno.h" before extern int errno;
cp qmail-dk /var/qmail/bin/qmail-dk
chown qmailq:qmail /var/qmail/bin/qmail-dk
chmod 4511 /var/qmail/bin/qmail-dk
-r-s--x--x 1 qmailq qmail 33844 Aug 26 17:15 /var/qmail/bin/qmail-dk
Patch qmail-scanner-queue.pl to sign messages
Code:
nano -w /var/qmail/bin/qmail-scanner-queue.pl
# approx line 1584
sub qmail_requeue {
my($sender,$env_recips,$msg)=@_;
my ($temp,$findate);
# check rcpthosts file for relaying domains
open(RCPTHOSTS, "</var/qmail/control/rcpthosts");
while (<RCPTHOSTS>) {
chomp;
if (/^$domain_returnpath$/i || $domain_returnpath =~ /$_$/i) {
# match found
# set DKSIGN variable to private key to sign with
# set DKQUEUE to original qmail-queue to spawn
$ENV{'DKSIGN'}='/etc/domainkeys/default';
$ENV{'DKQUEUE'}=$qmailqueue;
# set $qmailqueue to qmail-dk so qmail-scanner calls it to sign keys
$qmailqueue = '/var/qmail/bin/qmail-dk';
&minidebug("Signing message from $returnpath with a DomainKey");
}
}
close(RCPTHOSTS);
&debug("q_r: fork off child into $qmailqueue...");
Send a message to yourself and check the qmail-queue.log
Code:
tail /var/spool/qmailscan/qmail-queue.log
Signing message from [email]blah@blah.com[/email] with DomainKey
If you view the message source in Thunderbird you should see the DomainKey record
Code:
Comment: DomainKeys? See [url]http://antispam.yahoo.com/domainkeys[/url]
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
s=default; d=blah.com;
b=vHk1tQnQBvdfgdfgsfdS/FmrDgfdgbF/oaMhJpde1SsOGbiFKbqIjsYYxfm4KSP86b ;
You can also verify your DNS records using
http://domainkeys.sourceforge.net/policycheck.html
http://domainkeys.sourceforge.net/selectorcheck.html