How to configure DomainKey/DKIM in Mavericks Server?

I tried to follow the guid from TopicDesk (http://http://topicdesk.com/downloads/tutorials/160-implementing-domainkeys-dkim -on-os-x-10-8-x-mountain-lion-with-server-2-x) on 10.9.


My DNS is setup correctly (tested using the testing tools at domainkeys.sourceforge.net) and all is tested good.


I test that everything is registered correctly on the server with:

sudo -u _amavisd -H amavisd -c /Library/Server/Mail/Config/amavisd/amavisd.conf testkeys


and it passes, and I can successfully extract my public key with:

sudo -u _amavisd -H amavisd -c /Library/Server/Mail/Config/amavisd/amavisd.conf showkeys


When I receive signed messages, I can see the headers, but when I send email, I don't see any evidence that my email was signed by DKIM process.


how can I troubleshoot this an verify that amavisd is configured correctly?


I wonder also if the topicdesk.com article is incomplete.


Any help would be much appreciated!

Mac mini, OS X Server

Posted on Apr 17, 2014 5:11 PM

Reply
9 replies

Oct 18, 2017 6:14 AM in response to Michael Ojaste

Hey Michael O. I wanted to answer another question you had:

"2. When making the entries for other virtual domain what is the syntax?"


They way I got this to work for my other domains was to simply add an additional dkim_key() entry in

amavisd.conf
.


For example: topicdesk.com indicates that "right below

$enable_dkim_signing
" you will add the following entries:


dkim_key('mydomain.tld', 'default', '/var/db/dkim/mydomain.tld.default.pem');
@dkim_signature_options_bysender_maps = ( { '.' => { ttl => 21*24*3600, c => 'relaxed/simple' } } );


To add an additional virtual domain, using the same public/private key set, you would just add the following line after the first dkim_key() entry. For example, your results should look like this:


dkim_key('mydomain.tld', 'default', '/var/db/dkim/mydomain.tld.default.pem');

dkim_key('2ND_domain.tld', 'default', '/var/db/dkim/mydomain.tld.default.pem');

@dkim_signature_options_bysender_maps = ( { '.' => { ttl => 21*24*3600, c => 'relaxed/simple' } } );

This assumes you've added the same DNS entries to the 2ND_domain.tld public facing domain and don't want to use separate keys for each domain. You can easily use multiple keys by doing steps 4.1 again and replacing 'mydomain.tld' with '2ND_domain.tld' instead. You'll also need to separately run

sudo -u _amavisd -H amavisd -c /Library/Server/Mail/Config/amavisd/amavisd.conf showkeys

which will show you all public keys for each dkim_key() entry you've made in amavisd.conf. You take the one for displayed for 2ND_domain.tld and add that to the public facing default._domainkey.2ND_domain.tld TXT record.

The prefix 'default' in the TXT entry can be anything and is what's referenced in the line:

dkim_key('mydomain.tld', 'default', '/var/db/dkim/mydomain.tld.default.pem');

If you wanted to use different keys for different processes, you can have multiple dkim_key() line entries with corresponding DNS TXT records. For example:

Config: dkim_key('mydomain1.tld', 'default', '/var/db/dkim/mydomain1.tld.default.pem');

DNS: default._domainkey.mydomain1.tld TXT "v=DKIM1; p=MCIIxe4L0
..."

Config: dkim_key('mydomain2.tld', 'sales', '/var/db/dkim/mydomain2.tld.default.pem');

DNS: sales._domainkey.mydomain2.tld TXT "v=DKIM1; p=MCII-0dF78
..."

Config: dkim_key('mydomain3.tld', 'techsupport', '/var/db/dkim/mydomain3.tld.default.pem');

DNS: techsupport._domainkey.mydomain3.tld TXT "v=DKIM1; p=MCII7ythq9
..."

I'm watering things down a bit, but hope this helps!

-- Mike

Oct 17, 2017 4:44 PM in response to Michael Ojaste

Okay, so a little update now that I've spent the last 3 hours getting this to work on High Sierra with Server 5.4... To answer your question Michael O., you only need to have it setup on the public facing DNS. However, if you're hosting your internal DNS server on the same box as your mail server, it's a good idea to add the TXT entries to your respective zone db in /Library/Server/named/. This way, when performing the tests described by TopicDesk.com, you can verify that your configuration works. It's just double work when doing the DNS portion of the instructions, but worth it for testing. What Armand is summarizing is apparently very true, do not stop where the instructions seem to indicate you can stop, you must go forward with the Advanced configuration, which is actually a good general setup for most production servers. At least this was my experience, no singing would occur until the Advanced instructions were carried out. Helpful sites during testing: MX Toolbox's DKIM Test (If you followed the TopicDesk instructions, your selector is "default" without the quotes): https://mxtoolbox.com/dkim.aspx AdminSystem Software Limited's tools are fantastic. Click the Next Step key and you'll be given a test email to send to, and it will refresh with your headers analyzed: http://www.appmaildev.com/en/domainkey They also go on to describe how to use your personal Gmail account to verify DKIM sighing is taking place.

Apr 18, 2014 12:38 AM in response to Armand Welsh

I found my issue. I had a bad value in my amavis.conf .


I had


@dkim_signature_options_bysender_maps = ( { '.' => { a => rsa-sha256, ttl => 21*24*3600, c => 'relaxed/simple' } } );



but it should have been


@dkim_signature_options_bysender_maps = ( { '.' => { ttl => 21*24*3600, c => 'relaxed/simple' } } );



for some reason forcig he signing method caused the issue I was experiencing, but along the way, I did learn a lot about amavis-new and postfix, and how they interconnect.

Apr 30, 2014 11:26 AM in response to marchyman

It seems that step: 5. Advanced configuration options

http://topicdesk.com/downloads/tutorials/160-implementing-domainkeys-dkim-on-os- x-10-8-x-mountain-lion-with-server-2-x


is required to get it working with Mavericks/Server 3.1.1. At least that did the trick for me. The comment at the start of the section that said it should already be working wasn't true for my particular set up.

Apr 30, 2014 4:31 PM in response to marchyman

Sorry for not getting back to you. Yes, I too had to do the full implementation. this is because the second listener is used.


I already had this in my amavisd.conf

$interface_policy{'10026'} = 'ORIGINATING';


I did not add an new policy_bank, but I did change the order around a bit from the default.


$policy_bank{'ORIGINATING'} = { # mail supposedly originating from our users

originating => 1, # declare that mail was submitted by our smtp client

bypass_spam_checks_maps => [1],

allow_disclaimers => 1, # enables disclaimer insertion if available

# notify administrator of locally originating malware

virus_admin_maps => ["virusalert\@$mydomain"],

spam_admin_maps => ["virusalert\@$mydomain"],

warnbadhsender => 1,

# force MTA conversion to 7-bit (e.g. before DKIM signing)

smtpd_discard_ehlo_keywords => ['8BITMIME'],

# forward to a smtpd service providing DKIM signing service

forward_method => 'smtp:[127.0.0.1]:10027',

# Other special treatment of locally originating mail

bypass_banned_checks_maps => [1], # allow sending any file names and types

terminate_dsn_on_notify_success => 0, # don't remove NOTIFY=SUCCESS option

};



Even though the amavd.conf was already setup mostly correct, and expected port 10027 for the originating poicy_bank, postfix was not configured with a listenning channel on port 10027, so I added one (per the topicdesk example) by adding this to my master.cf:


127.0.0.1:10027 inet n - y - - smtpd

-o content_filter=

-o smtpd_tls_security_level=none

-o smtpd_delay_reject=no

-o smtpd_client_restrictions=permit_mynetworks,reject

-o smtpd_helo_restrictions=

-o smtpd_sender_restrictions=

-o smtpd_recipient_restrictions=permit_mynetworks,reject

-o smtpd_data_restrictions=reject_unauth_pipelining

-o smtpd_end_of_data_restrictions=

-o smtpd_restriction_classes=

-o mynetworks=127.0.0.0/8

-o smtpd_error_sleep_time=0

-o smtpd_soft_error_limit=1001

-o smtpd_hard_error_limit=1000

-o smtpd_client_connection_count_limit=0

-o smtpd_client_connection_rate_limit=0

-o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_m ilters

-o local_header_rewrite_clients=

-o smtpd_milters=

-o local_recipient_maps=

-o relay_recipient_maps=


But really, all of this is in the topicdesk blog. The key was you have to do a full implementation, you cannot stop where they suggest you can stop.

Aug 7, 2014 10:54 PM in response to Armand Welsh

Can someone add to this as to DNS entries and multiple domains. I read the topicdesk direction and want to get this going on my new OS X setup. I am ok with all the notes above but my public DNS is not hosted on my mail server. Rather then running a "split-horizon" setup I have my LAN DNS on the mail server and my WAN DNS on another mac-mini server currently running 10.6.8. So what I need to understand and know is:

1. Do the DKIM DNS Entries need to be on both servers or just the public/WAN one?

2. When making the entries for other virtual domain what is the syntax?


_domainkey.mydomain.tld TXT "o=~"


default._domainkey.mydomain.tld TXT "v=DKIM1; p=MIGfCSXUZqGSIb7DKI.-.-.-.-.-+43bMQIDAQAB"


Where mydomain = mail.qxxxxxn.com the FQDN of the mail server

For mydomainB = mail.qxxxxxn.net what goes in the .net Zone file?


?? default._domainkey.mydomainB.tld TXT "v=DKIM1; p=MIGfCSXUZqGSIb7DKI.-.-.-.-.-+43bMQIDAQAB" ??

Any other notes on this install would be helpful if you have done it in Mavericks, Thank you.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to configure DomainKey/DKIM in Mavericks Server?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.