Let me start by saying that I have never used haproxy, but this question was asked about 4 years ago and now has 4K views with no answers, so this was my experience with the exact same error using Dovecot & Thunderbird.
As it goes Thunderbird, and Firefox, do not use the system trust store. I assume that is common to a greater number of platforms.
After verifying the cert with openssl verify
, or openssl s_client
, You should check the root CA certificate in the client program.
In mozilla programs this can be done in about:preferences#privacy > View Certificates...
In my case I had a stale certificate so make sure to look at the details, or better, verify that the root CA in your client program matches the root CA that openssl is verifying against. A simple diff will work in this case.
Sometimes, it may be helpful to verify a cert against a private key, which can be done by comparing the pubkey.
openssl pkey -in key.pem -pubout | diff - <(openssl x509 -in cert.pem -pubkey -noout)
Mozilla Sidebar, I don't recommend this as it will duplicate a bunch of certs. It is also possible to have Thunderbird/Firefox look at the system trust store by going to about:preferences#privacy > Security Devices... > Load, and navigating to your p11-kit-trust.so. e.g. /lib/x86_64-linux-gnu/pkcs11/p11-kit-trust.so
https://support.mozilla.org/en-US/kb/setting-certificate-authorities-firefox
The Dovecot project has has a good writeup for testing to check whether there is a server or client problem.
https://wiki2.dovecot.org/TestInstallation &
https://doc.dovecot.org/configuration_manual/dovecot_ssl_configuration/#testing
However, that is not the full story since the introduction of the keyUsage constraint. A client may enforce this leading to a similar error: "sslv3 alert bad certificate: SSL alert number 42"
https://bugzilla.mozilla.org/show_bug.cgi?id=1036338
I found the following to be a good writeup including the creation of root/intermediate/client certs chainfiles & constraints.
https://jamielinux.com/docs/openssl-certificate-authority/create-the-root-pair.html