<div dir="ltr"><div dir="ltr"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 26, 2019 at 3:56 PM Marc Pujol <<a href="mailto:shadow%2Bamavis@la3.org">shadow+amavis@la3.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">A 26/03/2019 19:42, John Luk escrigué:<br>
<br>
> dkim_key('<a href="http://domain1.com" rel="noreferrer" target="_blank">domain1.com</a>', "dkim", "/var/lib/dkim/<a href="http://domain1.com" target="_blank">domain1.com</a>.pem");<br>
> dkim_key('<a href="http://domain2.com" rel="noreferrer" target="_blank">domain2.com</a>', "dkim", "/var/lib/dkim/<a href="http://domain2.com" target="_blank">domain2.com</a>.pem");<br>
> dkim_key('<a href="http://others.com" rel="noreferrer" target="_blank">others.com</a>', "dkim", "/var/lib/dkim/others.com.pem");<br>
> @dkim_signature_options_bysender_maps = ( {<br>
> "." => { d => "<a href="http://others.com" rel="noreferrer" target="_blank">others.com</a>", a => 'rsa-sha256', ttl => 10*24*3600 <br>
> },<br>
> });<br>
> <br>
> In my understanding the above would:<br>
> <br>
> * sign <a href="http://domain1.com" rel="noreferrer" target="_blank">domain1.com</a> using that <a href="http://domain1.com" rel="noreferrer" target="_blank">domain1.com</a> key<br>
> * sign <a href="http://domain2.com" rel="noreferrer" target="_blank">domain2.com</a> using that <a href="http://domain2.com" rel="noreferrer" target="_blank">domain2.com</a> key<br>
> <br>
> * sign domainX.com using that <a href="http://others.com" rel="noreferrer" target="_blank">others.com</a> key<br>
> * sign domainY.com using that <a href="http://others.com" rel="noreferrer" target="_blank">others.com</a> key<br>
> <br>
> Is that true?<br>
<br>
I don't think it is. The dkim_key entries only setup which keys are <br>
available, and then @dkim_signature_options_bysender_maps is what <br>
defines which signing domain to use depending on the sender address. <br>
Double-check the docs:<br>
<br>
<a href="https://www.ijs.si/software/amavisd/amavisd-new-docs.html#dkim-am-sign" rel="noreferrer" target="_blank">https://www.ijs.si/software/amavisd/amavisd-new-docs.html#dkim-am-sign</a> <br>
(point 7).<br>
<br>
In your case, you only have a catchall entry specifying that everything <br>
should be signed with under the <a href="http://others.com" rel="noreferrer" target="_blank">others.com</a> domain (and you only have one <br>
kay for that domain, so everything will be signed under d=<a href="http://others.com" rel="noreferrer" target="_blank">others.com</a> <br>
with the /var/lib/dkim/others.com.pem key).<br>
<br>
The correct setup would be:<br>
<br>
dkim_key('<a href="http://domain1.com" rel="noreferrer" target="_blank">domain1.com</a>', "dkim", "/var/lib/dkim/<a href="http://domain1.com" target="_blank">domain1.com</a>.pem");<br>
dkim_key('<a href="http://domain2.com" rel="noreferrer" target="_blank">domain2.com</a>', "dkim", "/var/lib/dkim/<a href="http://domain2.com" target="_blank">domain2.com</a>.pem");<br>
dkim_key('<a href="http://others.com" rel="noreferrer" target="_blank">others.com</a>', "dkim", "/var/lib/dkim/others.com.pem");<br>
@dkim_signature_options_bysender_maps = ( {<br>
".<a href="http://domain1.com" rel="noreferrer" target="_blank">domain1.com</a>" => { d => "<a href="http://domain1.com" rel="noreferrer" target="_blank">domain1.com</a>", a => 'rsa-sha256', ttl => <br>
10*24*3600 },<br>
".<a href="http://domain2.com" rel="noreferrer" target="_blank">domain2.com</a>" => { d => "<a href="http://domain2.com" rel="noreferrer" target="_blank">domain2.com</a>", a => 'rsa-sha256', ttl => <br>
10*24*3600 },<br>
"." => { d => "<a href="http://others.com" rel="noreferrer" target="_blank">others.com</a>", a => 'rsa-sha256', ttl => 10*24*3600 },<br>
});<br>
<br>
Comments:<br>
<br>
- Notice that the signing domain doesn't need to be the same as the <br>
sender domain. For instance, gmail will sign all its outgoing mails <br>
under the <a href="http://gmail.com" rel="noreferrer" target="_blank">gmail.com</a> domain, even gmail for businesses with their own <br>
domain. In this example all emails except those of <a href="http://domain1.com" rel="noreferrer" target="_blank">domain1.com</a> and <br>
<a href="http://domain2.com" rel="noreferrer" target="_blank">domain2.com</a> would be signed under the <a href="http://others.com" rel="noreferrer" target="_blank">others.com</a> domain (not under their <br>
own).<br>
<br>
- Like in other maps, ".<a href="http://domain1.com" rel="noreferrer" target="_blank">domain1.com</a>" (with the initial dot) matches both <br>
<a href="http://domain1.com" rel="noreferrer" target="_blank">domain1.com</a> domain and any of its subdomains, whereas "<a href="http://domain1.com" rel="noreferrer" target="_blank">domain1.com</a>" <br>
doesn't match subdomains.<br>
<br>
- Of course you can adapt the extra parameters (a, ttl, whatever) to <br>
your liking.<br>
<br></blockquote><div>Thanks for your timely reply, and for the explanation.</div><div><br></div><div>The funny thing is, there is no dkim_signature_options_bysender_maps found in our amavis conf, yet it has no problem signing for domain1 and domain2 for years.</div><div><br></div><div><a href="https://www.ijs.si/software/amavisd/amavisd-new-docs.html#dkim-am-sign" rel="noreferrer" target="_blank">https://www.ijs.si/software/amavisd/amavisd-new-docs.html#dkim-am-sign</a> is a great link, thanks. Although its point 7 for dkim_signature_options_bysender_maps said it is "Optional". And in point 2 and point 3 one can already do "showkeys" and "testkeys" without adding dkim_signature_options_bysender_maps. Also point 2 is for:</div><div><br></div><div>"<b>2.</b> Add commands to amavisd.conf to load private keys,
associate them with signing domains and selectors, and describe
constraints (tags) to be published with public keys."</div><div><br></div><div>So does it mean, "dkim_key" has already defined the signing key for that sender domain?<br><pre>Thanks!<br></pre></div></div></div>