Solved Sendmail dh key too small

I have just updated a server from 10.1-RELEASE-p9 to 10.1-RELEASE-p12. The daily reports should be forwarded to me by email. Since the update, sendmail cannot move mail from the clientmqueue to the mqueue, with errors like:

Code:
Jun 13 03:01:49 motoko sendmail[3050]: t5D31nxX003050: from=root, size=9823, class=0, nrcpts=1, msgid=<201506130301.t5D31nxX003050@motoko.rdls.net>, relay=root@localhost
Jun 13 03:01:49 motoko sendmail[3050]: STARTTLS=client, error: connect failed=-1, reason=dh key too small, SSL_error=1, errno=0, retry=-1
Jun 13 03:01:49 motoko sendmail[3050]: ruleset=tls_server, arg1=SOFTWARE, relay=[127.0.0.1], reject=403 4.7.0 TLS handshake.
Jun 13 03:01:49 motoko sm-mta[3072]: STARTTLS=server, error: accept failed=0, reason=sslv3 alert handshake failure, SSL_error=1, errno=0, retry=-1, relay=localhost [127.0.0.1]
Jun 13 03:01:49 motoko sendmail[3050]: t5D31nxX003050: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=39823, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: 403 4.7.0 TLS handshake.
Jun 13 03:01:49 motoko sm-mta[3072]: t5D31nPt003072: localhost [127.0.0.1] did not issue MAIL/EXPN/VRFY/ETRN during connection to Daemon0
It seems to me that this problem is related to a recent SSL update and the minimum key size. The day before the update, the above messages looked like this:

Code:
Jun 12 03:01:22 motoko sendmail[39198]: t5C31M4U039198: from=root, size=764, class=0, nrcpts=1, msgid=<201506120301.t5C31M4U039198@motoko.rdls.net>, relay=root@localhost
Jun 12 03:01:22 motoko sm-mta[39239]: STARTTLS=server, relay=localhost [127.0.0.1], version=TLSv1/SSLv3, verify=NO, cipher=DHE-RSA-AES256-GCM-SHA384, bits=256/256
Jun 12 03:01:22 motoko sendmail[39198]: STARTTLS=client, relay=[127.0.0.1], version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-GCM-SHA384, bits=256/256
Jun 12 03:01:22 motoko sendmail[39244]: t5C31MZg039244: from=root, size=2542, class=0, nrcpts=1, msgid=<201506120301.t5C31MZg039244@motoko.rdls.net>, relay=root@localhost
...and then it went on to send the email to an external mail server.

This server is a very simple bridging firewall, so there are only a few places to look for keys. The /etc/mail/cert/ directory contained some files which were a year old, but openssl x509 showed that they had key lengths of 2048 bits. I regenerated them anyway, by renaming the directory and restarting the sendmail service.

I do not understand where the 256/256 key size comes from. The next step will be to perform a fresh install. Am I missing something obvious?

Thanks for taking the time to read this.
 
In 10.1-RELEASE-p12 OpenSSL has been updated and it fixes the Logjam Attack. Among other measures, it does this by not allowing Diffie-Hellman keys of a length below 768 bit (in later versions the minimum DH key length parameter will be bumped to 1024 bit). It is recommended to generate new DH keys for the services utilizing DH key exchange of a length of at least 1024 or even better of 2048 bit.
openssl gendh -out dh_2048.pem -2 2048

Then you need to place the newly generated DH key where sendmail expects it. (Sorry, I am not familiar with sendmail, and cannot be of help in this particular respect.)
 
In 10.1-RELEASE-p12 OpenSSL has been updated and it fixes the Logjam Attack. Among other measures, it does this by not allowing Diffie-Hellman keys of a length below 768 bit (in later versions the minimum DH key length parameter will be bumped to 1024 bit). It is recommended to generate new DH keys for the services utilizing DH key exchange of a length of at least 1024 or even better of 2048 bit.
openssl gendh -out dh_2048.pem -2 2048
That's about as far as I got too. The problem is that Sendmail doesn't work out of the box anymore (which was the only reason I was still using it), and I am reluctant to start trying to customise Sendmail, because I know it will all end in pain.

So, I've replaced Sendmail with PostFix configured as a null client and it's all working perfectly :)

Thanks for replying.
 
I looked at /etc/rc.d/sendmail and I saw it will regenerate the ssl keys. So I stopped sendmail, removed the files in /etc/mail/certs and restarted. Same issue :(

So I did what obsigna suggested and copied the file created to /etc/mail/certs/cacert.pem and issue is now fix.

But that makes me wonder if /etc/rc.d/sendmail needs to be updated ? I looked at it and
Code:
sendmail_cert_create()
is a bit too complex for me.

John
 
Hi,

Same problem here.

Commands below should fix the issue...

cd /etc/mail/certs
openssl dhparam -out dh.param 4096
cd /etc/mail && make restart

I thought the same as you celt, however it doesn't solve the issue. What else could it be ?

Cheers.
 
Commands below should fix the issue...

cd /etc/mail/certs
openssl dhparam -out dh.param 4096
cd /etc/mail && make restart
I used your suggestion on a test box running 10.1-R-p12, but I made the key length 1024 (as 4096 takes forever), and rebooted.

It fixes the problem. I have marked this question solved. Thanks.
 
Hi,

Same problem here.

I thought the same as you celt, however it doesn't solve the issue. What else could it be ?
If you are using a custom /etc/mail/sendmail.cf file, check that the path to the certificate file has been defined (from /etc/mail/freebsd.mc):
Code:
define(`confDH_PARAMETERS', `CERT_DIR/dh.param')dnl
 
This worked for me too. It was very frustrating this weekend, discovering that the update to sendmail had killed status notifications from my servers. It's nice to have them back on line with the security key. It's a shame sendmail won't work out of the box anymore.
 
Thanks, that has solved it for me too. It took me a while to stumble upon this thread but I am glad that I finally found it, thank you very much.
 
It seemed that I had to do a full stop and start of Sendmail. A make restart was not enough. I did not look into why.
 
I have the same problem here. And I do follow the link http://www.freebsd.org/doc/handbook/openssl.html

Then follow with above reccommendation
Code:
> cd /etc/ssl
>openssl req -new -nodes -out req.pem -keyout cert.key -sha256 -newkey rsa:2048
....
>openssl req -new -x509 -days 3650 -key cert.key -out cert.crt -sha256
....

>edit /etc/rc.conf

Then add following 2 lines to file
Code:
sendmail_cert_create="YES"
sendmail_cert_cn="localhost.mydomain.com"

Then
Code:
>service sendmail restart

>cd /etc/mail/certs
>openssl dhparam -out dh.param 2048
>cd /etc/mail && make restart

I just change to 2048 is enough, cause I afraid to use 4096 will too much to consume on network bandwidth and make connection slow.

But now, even I haven't reboot cause changing rc.conf, the problem of mention in the topic got solved now.
(no problem of "STARTTLS=server, error: accept failed=0, reason=sslv3 alert handshake failure, SSL_error=1, errno=0 ...." any more)

And I have some questions:
1. Do I still need to put following configs (to /etc/rc.conf)? (as mention in link http://www.freebsd.org/doc/handbook/openssl.html)
Code:
sendmail_cert_create="YES"
sendmail_cert_cn="localhost.mydomain.com"

I just put it and have not do any reboot. (just to ask in the forum first for more information, before decision to make reboot)

Any suggestion? (Sorry, I got little knowledge about OpenSSL + encryption key)

Note: I use FreeBSD 10.1-STABLE, Sendmail version 8.14.9, config V10/Berkeley.
 
Back
Top