redneb / HsOpenSSL-x509-system

Use the system's native CA certificate store with HsOpenSSL
https://hackage.haskell.org/package/HsOpenSSL-x509-system
BSD 3-Clause "New" or "Revised" License
5 stars 2 forks source link

Correct certificate storage lookup order for FreeBSD #2

Closed herrhotzenplotz closed 4 years ago

herrhotzenplotz commented 4 years ago

Previously on FreeBSD the path /usr/local/share/certs was found first and caused the main lookup loop (in contextLoadSystemCerts in Unix.hs) to exit. Since this directory only contains one certificate bundle and not single certificates, the loop exited and no certificates were loaded. By altering the order of the search paths, the root certs are recognized correctly on FreeBSD.

This issue appeared while using hookup together with irc-core. It worked perfectly fine on GNU/Linux but when moving it to FreeBSD no connection could be established.

Confirmed to be working on FreeBSD 12.1-RELEASE-p8 amd64 and GNU/Linux Archlinux 5.4.57-lts x86_64.

Please tell me if any issues arise from this.

redneb commented 4 years ago

Hi and thanks for the PR!

I did a quick investigation using FreeBSD 12.1 and you are right, /usr/local/share/certs/ca-root-nss.crt should be higher that /usr/local/share/certs. But I also noticed that FreeBSD creates by default a symlink, /etc/ssl/cert.pem, which points to /usr/local/share/certs/ca-root-nss.crt. So I think that /etc/ssl/cert.pem should be higher than the two aforementioned paths:

Accordingly, I pushed a commit to master that implements the change I describe above. Could you please test it by compiling from git? If you confirm that it works, I will publish it as a new version in hackage.

herrhotzenplotz commented 4 years ago

@redneb Thanks for answering. You're completely correct. The lookup works with your changes. I'd be happy if you push those changes to hackage. With that being said, I'll close this PR once the new version is published.

redneb commented 4 years ago

0.1.0.4 is not available on hackage. Thanks for the help!