Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DKIM generated key do not use HOSTNAME env var #1291

Closed
fred727-temp opened this issue Oct 14, 2019 · 11 comments
Closed

DKIM generated key do not use HOSTNAME env var #1291

fred727-temp opened this issue Oct 14, 2019 · 11 comments

Comments

@fred727-temp
Copy link

Context

Fill .env file whith for example HOSTNAME=test
Then, run ./setup.sh config dkim

Expected Behavior

2 files config/opendkim/keys/domain.tld/test.txt and config/opendkim/keys/domain.tld/test.private

Actual Behavior

"mail" is used instead of HOSTNAME
2 files config/opendkim/keys/domain.tld/mail.txt and config/opendkim/keys/domain.tld/mail.private are created

@erik-wramner
Copy link
Contributor

Actually I think this is working as designed (though it wasn't my design). All the documentation I have seen says that mail will be used; as far as I can tell host name is never mentioned?

@fred727-temp
Copy link
Author

For me, the ./setup.sh script must be adapted. The doc say that setup.sh create dkim keys, This is not always correct and confusing...
Change is not difficult : it is only a -s parameter to set when creating dkim keys.

@erik-wramner
Copy link
Contributor

I'm afraid I don't follow. From the docs:

Generate DKIM keys
./setup.sh config dkim
Now the keys are generated, you can configure your DNS server by just pasting the content of config/opendkim/keys/domain.tld/mail.txt in your domain.tld.hosts zone.

It says mail and as far as I can see there is nothing to adapt and no mention of hostname? In what way is it not always correct that the setup command creates the keys?

@fred727-temp
Copy link
Author

In the container, file /usr/local/bin/generate-dkim-config contain the line :
opendkim-genkey --bits=$keysize --subdomains --domain=$domainname --selector=mail -D /tmp/docker-mailserver/opendkim/keys/$domainname

It is not difficult to put a variable instead of --selector=mail to get the HOSTNAME and all would be fine...

@erik-wramner
Copy link
Contributor

No it would not be difficult, but we are talking in circles. You say that it is wrong because it is A instead of B but the documentation says that it should be A.

All the documentation I can find in this project agrees that the selector argument should be "mail", so it is not an error that it actually is "mail" and not host name. It is not unexpected or confusing, it is working as designed and documented. Please find where in the docker-mailserver documentation it says that selector should be host name and not mail if I have missed it. I don't think I have, though.

@fred727-temp
Copy link
Author

I read the doc... I understood that this container could be parameterized... And I understood that the env var HOSTNAME is for this purpose...

OK, all the doc speak about a hostname equal to mail. But it is not say that we MUST use mail to let this project work.

If you choose another domain, it will not work out of the box. Because the dkim check won't be ok !! Check the outgoing email with the validator of your choice, you will see...

So for me it is a bug. If you do not want to make the change, add in the doc that hostname MUST be mail.

Thank you for your work and excuse my bad english (I'm just a poor little frechy ;)
Just want to contribute, not borring you...

Regard,

@erik-wramner
Copy link
Contributor

It is not a bug, it is working as designed and the host name does not have to be mail.

The DKIM selector is mail. Not the host name. The host name can be anything. It does not have to be the same as the DKIM selector. And it works quite well when you have several domains. I have several domains and I know others using docker-mailserver that also have several domains. Each domain gets its own DKIM record. You need to generate one per domain, so config/opendkim/keys/domain.tld/mail.txt and config/opendkim/keys/second-domain.tld/mail.txt and so on.

The DKIM selector is an arbitrary string representing a service. In this case the "mail" service. It is not a host name.

I hope that cleared things up? I really don't think there is anything wrong here, I think you have misunderstood the documentation. This image has 20M docker pulls, so someone should have noticed if the basic installation instructions were totally wrong :-).

@fred727-temp
Copy link
Author

OK I understand. Your choice is to force the DKIM selector with the value "mail".

For my part, I deployed this docker image to create a second mail server. The first was mail.domain.tld and the new mail2.domain.tld.
I already had a DKIM record on the selector "mail" and did not want to use the same for the new server (I do not know if there are good practices on this point).
I thought that automatically, you would have used the HOSTNAME to generate the selector but it was not the case and so I had to intervene manually.
Maybe you could add an optional environment variable for that ?

Last thing if I can... In the section Get the tool of the doc, you should add

    curl -o env-mailserver https://raw.githubusercontent.com/tomav/docker-mailserver/master/env-mailserver.dist

Because docker-compose.yml refer to it...

Regards,

@erik-wramner
Copy link
Contributor

Well, I'm the new kid on the block here so it wasn't my decision, but that is the design. Personally I've just copied the DKIM keys to all my servers within a domain, not sure if that is good or bad but it works. Good point about the documentation.

@fred727-temp
Copy link
Author

Could you please tag this topic as "Evolution" to ask a new env var for the DKIM Section ?

It is nothing to do and it could be so usefull ;)

Thank you

@erik-wramner
Copy link
Contributor

I created #1304 for that. The feature has been requested before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants