Froxlor icon indicating copy to clipboard operation
Froxlor copied to clipboard

Implement Openkdim

Open llucps opened this issue 5 years ago • 28 comments

Since dkim-filter is deprecated it would be great to implement its replacement Openkdim.

I set up dmarc reports on my server and neither Yahoo and [email protected] don't like the current dkim-filter implementation. On [email protected] complains about the dkim selector having an underscore. Fortunately Google doesn't complain and passes de dmarc test.

----------------------------------------------------------
DKIM check details:
----------------------------------------------------------
Result:         permerror (syntax error in s= tag: Error in "dkim_1": invalid character U+005F ('_') in domain label)
ID(s) verified: 

DNS record(s):

NOTE: DKIM checking has been performed based on the latest DKIM specs
(RFC 4871 or draft-ietf-dkim-base-10) and verification may fail for
older versions.  If you are using Port25's PowerMTA, you need to use
version 3.2r11 or later to get a compatible version of DKIM.

llucps avatar Dec 27 '18 15:12 llucps

Froxlors DKIM implementation is really really old - don't use that currently

d00p avatar Dec 28 '18 09:12 d00p

It will be easier to have a hook to run a script on (sub)domain creation - there we can create DKIM keys for OpenDKIM, Rspamd etc. etc.

negrusti avatar Feb 26 '19 16:02 negrusti

creation of key is not the problem...the using service and integration is

d00p avatar Feb 26 '19 17:02 d00p

I don't think any other integration is needed IF DNS is not managed on the server. At the moment I just run the script that pulls domains from Froxlor DB and generates the keys, everything else works (OpenDKIM or Rspamd). But I need to remember to run that script after domain creation

negrusti avatar Feb 26 '19 17:02 negrusti

I could probably work on this. Should I just ditch dkim-milter and implement OpenDKIM or let the user select between the 2?

Logicbloke avatar Feb 26 '19 17:02 Logicbloke

I think I've not seen dkim-milter in production for quite a while... Can assist with OpenDKIM config if necessary

negrusti avatar Feb 26 '19 17:02 negrusti

dkim-milter is not really used anymore. Config templates for OpenDKIM would be nice

d00p avatar Feb 26 '19 17:02 d00p

/etc/opendkim.conf:

AutoRestart Yes AutoRestartRate 10/1h UMask 002 Syslog yes SyslogSuccess Yes LogWhy Yes ReportAddress [email protected] Canonicalization relaxed/simple ExternalIgnoreList refile:/etc/opendkim/TrustedHosts InternalHosts refile:/etc/opendkim/TrustedHosts KeyTable refile:/etc/opendkim/KeyTable SigningTable refile:/etc/opendkim/SigningTable Mode sv PidFile /var/run/opendkim/opendkim.pid SignatureAlgorithm rsa-sha256 UserID opendkim:opendkim Socket inet:12301@localhost

/etc/opendkim/KeyTable:

default._domainkey.example.com example.com:default:/etc/opendkim/keys/example.com/default.private

/etc/opendkim/SigningTable:

*@example.com default._domainkey.example.com

/etc/opendkim/TrustedHosts:

127.0.0.1 localhost

negrusti avatar Feb 26 '19 18:02 negrusti

Key generation: mkdir -p /etc/opendkim/keys/example.com
opendkim-genkey -r -d example.com -D /etc/opendkim/keys/example.com
chown opendkim:opendkim /etc/opendkim/keys/example.com/default.private

public key will be in /etc/opendkim/keys/example.com/default.txt

negrusti avatar Feb 26 '19 18:02 negrusti

Postfix:

milter_protocol = 2 milter_default_action = accept smtpd_milters = inet:localhost:12301 non_smtpd_milters = inet:localhost:12301

negrusti avatar Feb 26 '19 18:02 negrusti

Rspamd Key generation:

rspamadm dkim_keygen -b 2048 -d example.com -s default -k /var/lib/rspamd/dkim/example.com.default.key > /var/lib/rspamd/dkim/example.com.default.public

dkim_signing.conf:

path = "/var/lib/rspamd/dkim/$domain.$selector.key";

and it will pick up the keys automatically

negrusti avatar Feb 26 '19 18:02 negrusti

Ehm, lib/configfiles/*.xml and pull request?

d00p avatar Feb 26 '19 19:02 d00p

I hope @Logicbloke can help with that :)

negrusti avatar Feb 26 '19 19:02 negrusti

It seems that while opendkim.conf can be configured manually, things like KeyTable, SigningTable or TrustedHosts will need to be generated.

Also even within opendkim.conf some people would want the SignatureAlgorithm and the port in Socket configurable.

As far as key generation is involved, I think Froxlor is already doing it. Needs another standardized name for the keys (preferably without the underscore) which is what this ticket is about.

I'll see what I can do with the configuration, I have the project forked.

Logicbloke avatar Feb 26 '19 20:02 Logicbloke

Also even within opendkim.conf some people would want the SignatureAlgorithm and the port in Socket configurable.

Yeah but openDKIM is, like postfix/docecot, a one-time-configuration. Nothing froxlor generates regularly via cronjob. And same as FTP or mail-services, the user can adjust any part of it or ports according to his needs. But not from within the GUI, that would be madness, too many options :)

d00p avatar Feb 27 '19 06:02 d00p

So please stay as close to the standaed/default configuration and only adjust necessary parts (like we do that for every service)

d00p avatar Feb 27 '19 06:02 d00p

Absolutely, so the only thing Froxlor needs to do is to create/update these two: /etc/opendkim/KeyTable /etc/opendkim/SigningTable generate the keys, and be able to restart opendkim

negrusti avatar Feb 27 '19 08:02 negrusti

Is there any SQL interface to let OpenDKIM read that from the database?

d00p avatar Feb 27 '19 09:02 d00p

Yes there is: https://github.com/cyrusimap/opendkim/blob/master/opendkim/README.SQL But this will require additional systemd configuration for OpenDKIM to start it after MySQL

negrusti avatar Feb 27 '19 09:02 negrusti

then it would be nice if the one doing the configs could do it the SQL way, as we do that the same with postfix, ftp, etc.

d00p avatar Feb 27 '19 09:02 d00p

@d00p Do you know of a handy GUI XML editor? The files are huge and the structure isn't well-outlined when opening it on a text-editor.

Logicbloke avatar Feb 27 '19 22:02 Logicbloke

Any IDE can handle XML fine. I like PhpStorm as my IDE.

pquerner avatar May 03 '19 22:05 pquerner

What's the problem here? Is anybody working on OpenDKIM? I have been running it with Froxlor the last few years and would be able to copy my implementation into a PR, and make it look a bit nicer, etc if nobody else has done anything for OpenDKIM.

makuser avatar Jul 30 '19 08:07 makuser

Problem as always, time time time and no one wants to do it for ALL supported systems (config templates are required for this for sure). If you want to get this going, hell yeah go for it :)

d00p avatar Jul 30 '19 08:07 d00p

Config templates are so damn easy. Near stock actually. OpenDKIM is much easier to implement compared to dkim-milter, as it already supports SQL OOTB.

Will do.

makuser avatar Jul 30 '19 08:07 makuser

@d00p Can we just ditch the underscore in the dkim txt record?

root@server:/var/www/froxlor# grep -rwb . -e dkim_ ./lib/Froxlor/Dns/Dns.php:4939: self::addRequiredEntry('dkim_' . $domain['dkim_id'] . '.domainkey', 'TXT', $required_entries); ./lib/Froxlor/Dns/Dns.php:10261: } elseif ($record == 'dkim' . $domain['dkim_id'] . '.domainkey' && ! empty($dkim_entries)) { ./lib/Froxlor/Cron/Dns/DnsBase.php:6225: $privkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim' . $domain['dkim_id']); ./lib/Froxlor/Cron/Dns/DnsBase.php:6351: $pubkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id'] . '.public'); ./lib/Froxlor/Cron/Dns/DnsBase.php:6811: $privkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id']); ./lib/Froxlor/Cron/Dns/DnsBase.php:7231: $pubkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id'] . '.public');

I guess this should solve OP's issue.

Logicbloke avatar Jul 30 '20 05:07 Logicbloke

Even though removing the underscore was the right thing, I did not cover or update that in my opendkim config, and it bit me just now, when I contacted one (non-Google) mail server that actually did check this.

makuser avatar Aug 23 '21 11:08 makuser

To follow this important ticket :)

Neustradamus avatar Oct 29 '23 18:10 Neustradamus