<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>All About LAMP &#187; fedora</title>
	<atom:link href="http://allaboutlamp.com/tag/fedora/feed/" rel="self" type="application/rss+xml" />
	<link>http://allaboutlamp.com</link>
	<description>Create web applications with Linux, Apache, MySQL, PHP and other open source technologies</description>
	<lastBuildDate>Sun, 08 Jan 2012 15:45:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Setup DKIM for Postfix in Fedora using dkim-milter</title>
		<link>http://allaboutlamp.com/2009/09/setup-dkim-for-postfix-in-fedora-using-dkim-milter/</link>
		<comments>http://allaboutlamp.com/2009/09/setup-dkim-for-postfix-in-fedora-using-dkim-milter/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 16:02:29 +0000</pubDate>
		<dc:creator>Daniel Lam</dc:creator>
				<category><![CDATA[Email]]></category>
		<category><![CDATA[dkim]]></category>
		<category><![CDATA[dkim-milter]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[postfix]]></category>

		<guid isPermaLink="false">http://allaboutlamp.com/?p=1</guid>
		<description><![CDATA[This article describes how to implement DKIM for Postfix in Fedora using the dkim-milter open-source module. This solution has been tested with Fedora 10.]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><strong>Overview</strong></span></p>
<p>DKIM is a technology that allows mail senders to attach a signature in outgoing mails, so that recipients can check the signatures against DNS records of the sender to see if mail is indeed sent from there.</p>
<p>Because free email providers like gmail make use of DKIM to determine if sender is sending spam, i.e. &#8220;if your domain does not implement DKIM, you are a spammer&#8221;, it is important to implement DKIM for your mail servers to avoid your legitimate out-going emails be classified as spam.</p>
<p><span style="text-decoration: underline;"><strong>Context</strong></span></p>
<p>This article describes how to implement DKIM for Postfix in Fedora using the dkim-milter open-source module. This solution has been tested with Fedora 10.</p>
<p>DKIM allows a domain to be associated with multiple &#8220;signatures&#8221;. Each signature is identified by its &#8220;selector&#8221;. In this example, we are going to create only one signature with its selector named &#8220;default&#8221;.</p>
<p><span style="text-decoration: underline;"><strong>Steps</strong></span></p>
<p><strong>1. Generate a private key</strong></p>
<p><code>openssl genrsa -out default.private 1024</code></p>
<p>A &#8220;default.private&#8221; key file will be generated. It will be moved to a specific location later.</p>
<p><strong>2. Generate a public key for this private key</strong></p>
<p><code>openssl rsa -in default.private -pubout -out default.public -outform PEM</code></p>
<p>A file with filename &#8220;default.public&#8221; will be generated with content like</p>
<p>	<code>-----BEGIN PUBLIC KEY-----<br />
	MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVqyBW3CvurzAJrWvw/rbiMVL2<br />
	6lytBkhIrgEBWjGWEjjhM6mQpQWLq9VR46xlL4OT6UdVtO8QOMEVI23LN0fwtrPc<br />
	/auwHC2U9joUWTWVjOMZWEywOHwATGevh9TApt2hQJkWjMy/xmCIqBs9VZIweRlf<br />
	VFqc9WEu6VamGe9C3QIDAQAB<br />
	-----END PUBLIC KEY----</code></p>
<p>It will be used to create a DNS TXT record. See next step.</p>
<p><strong>3. Create a DNS record of type TXT</strong></p>
<p>Modify DNS records and add a record of type TXT:</p>
<p>TXT record name<br />
<code>default._domainkey</code></p>
<p>TXT record value<br />
<code>v=DKIM1; g=*; k=rsa; p=<i>&lt;content of default.public&gt;</i></code></p>
<p>Note that the prefix &#8220;&#8212;&#8211;BEGIN PUBLIC KEY&#8212;&#8211;&#8221; and suffix &#8220;&#8212;&#8211;END PUBLIC KEY&#8212;-&#8221; should not be put in the TXT record value.</p>
<p>This DNS record will be retrieved by mail receivers who want to verify emails with DKIM signatures. The record name &#8220;default._domainkey&#8221; tells verifier that the &#8220;selector&#8221; of this signature is  &#8220;default&#8221;, therefore if you are changing selector name to something else, make sure you change all of them consistently.</p>
<p><strong>4. Install dkim-milter in Fedora</strong></p>
<p>Run the following as root to install the dkim-milter pacakge.</p>
<p><code>yum install dkim-milter</code></p>
<p><strong>5. Enable dkim-milter to run on start-up</strong></p>
<p>Make sure dkim-milter service will run on start-up by running this command:</p>
<p><code>chkconfig --level 3 dkim-milter on</code></p>
<p>Note that your server may use a different &#8220;runlevel&#8221;. You can check &#8220;/etc/inittab&#8221; to see which run level you are on.</p>
<p><strong>6. Move private key to appropriate location</strong></p>
<p>As root, copy the private key to the location specified by the &#8220;keylist&#8221; (refer to next step) and make sure it is readable by dkim-milter:</p>
<p><code>mkdir /etc/dkim-milter/<br />
mv default.private /etc/dkim-milter/default<br />
chown dkim-milter.dkim-milter /etc/dkim-milter/default</code></p>
<p>Make sure the filename of private key file matches the &#8220;selector&#8221; name specified in the DNS record.</p>
<p><strong>7. Add an entry to the keylist for dkim-milter to read</strong></p>
<p>Add the following line to /etc/mail/dkim-milter/keys/keylist. Replace &lt;domain.com&gt; with your domain name.</p>
<p><code>*:&lt;domain.com&gt;:/etc/dkim-milter/default</code></p>
<p><strong>8. Configure postfix to use dkim-milter</strong></p>
<p>Add the following lines to /etc/postfix/main.cf to ask postfix to use dkim-milter.</p>
<p><code>smtpd_milters = unix:/var/run/dkim-milter/dkim-milter.sock<br />
non_smtpd_milters = unix:/var/run/dkim-milter/dkim-milter.sock</code></p>
<p><strong>9. Start dkim-milter and restart postfix</strong></p>
<p>Start dkim-milter service and restart postfix using the following commands. Or restart the server.</p>
<p><code>service dkim-milter start<br />
service postfix restart</code></p>
<p><strong>10. Change file permissions of the Mail Filter Socket file</strong></p>
<p>Change file permissions of the &#8220;Mail Filter Socket&#8221; file and its parent directory to allow postfix to write to it:</p>
<p><code>chmod 755 /var/run/dkim-milter<br />
chmod 777 /var/run/dkim-milter/dkim-milter.sock</code></p>
<p>Changing dkim-milter.sock permission unfortunately is required EVERYTIME after dkim-milter servuce is restarted. This is because dkim-milter resets the file to mode 755 that postfix cannot read.</p>
<p>For Fedora, one way to have this done automatically is to add the chmod command in /etc/rc.d/rc.local, so that it will be run on start-up everytime.</p>
<p><span style="text-decoration: underline;"><strong>Errors / Configuration Problems</strong></span></p>
<p><strong>Gmail header says &#8220;dkim=neutral (body hash did not verify)&#8221;</strong></p>
<p>If you are sending emails using mail() function in php, these out-going emails will not be verified by Gmail, for some unknown reason. Opening the mail source in Gmail shows that there is a line &#8220;dkim=neutral (body hash did not verify)&#8221;, hinting that the key in DKIM signature does not match the public key from DNS. Only Gmail knows why. </p>
<p>You may also notice that sending emails directly from the command-line in your server will be DKIM-verified by Gmail, resulting in a &#8220;dkim=pass&#8221; in the mail source headers. Therefore, a work-around for this problem is to modify your php scripts so that it will do a system call to a shell script, which will indirectly send your email out. This way, Gmail will verify your email and put it to the inbox of recipient instead of marking it as spam.</p>
<p><strong>Gmail header says &#8220;dkim=neutral (no key)&#8221; </strong></p>
<p>It means that gmail couldn&#8217;t find a matching key to verify your signature.</p>
<p>So, how does gmail (or any other dkim verifier) find a matching key? It relies on the &#8220;selector name&#8221; from the email header. In the email header there should be something like &#8220;DKIM-Signature: &#8230; s=some_selector_name; t=1254783208;&#8230;&#8221;, here the &#8220;some_selector_name&#8221; is the selector name. Dkim-milter specified that as your selector name as instructed by /etc/mail/dkim-milter/keys/keylist file.</p>
<p>Now if you look at the DNS record for your domain, it needs to have a DKIM public key record (TXT type DNS record) with the name &#8220;some_selector_name._domainkey&#8221; and value being the matching public key. If the name of the record is not &#8220;some_selector_name._domainkey&#8221;, the verifier will not be able to use the public key, because the selector name does not match.</p>
<p>You might have followed an example from internet to set your selector name to &#8220;domain.com_default.key.pem&#8221; and the DNS record name to &#8220;default._domainkey&#8221;, which are not matching each other and therefore getting this no-key message.</p>
<p><span style="text-decoration: underline;"><strong>Reference</strong></span></p>
<ul>
<li><a href="http://www.howtoforge.com/postfix-dkim-with-dkim-milter-centos5.1">http://www.howtoforge.com/postfix-dkim-with-dkim-milter-centos5.1</a> Instructions similar to this article, but for CentOS instead of Fedora. </li>
<li><a href="http://testing.dkim.org/reflector.html">http://testing.dkim.org/reflector.html</a> Free testing to check if your DKIM implementation works.</li>
<li>Config files related to dkim-milter in Fedora:
<p>	Socket file that Postfix connects to<br />
	<code>/var/run/dkim-milter/dkim-milter.sock</code></p>
<p>	Key List file<br />
	<code>/etc/mail/dkim-milter/keys/keylist</code></p>
<p>	Actual private key (can be anywhere as specified by &#8220;Key List&#8221;)<br />
	<code>/etc/dkim-milter/&lt;key filename&gt;</code></p>
<p>	Config file<br />
	<code>/etc/mail/dkim-milter/dkim-filter.conf</code></p>
<p>	Another config file but does not appear to be read by the service<br />
	<code>/etc/sysconfig/dkim-milter</code></p>
<p>	Postfix config that specifies where dkim-milter socket is:<br />
	<code>/etc/postfix/main.cf </code>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://allaboutlamp.com/2009/09/setup-dkim-for-postfix-in-fedora-using-dkim-milter/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

