Fails properly when system certificates can't be found #63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The code right now assumes that system certificates on macOS will be in /etc/ssl, but this folder might not even exist, in which case the certificates should be loaded from the keychain. If you don't have that folder on your system, the code would take a second path where it would use certificates bundled with the code, which only works when you have the source code available. The code assumes these exists, through, and will fail with a very unhelpful "No such file or directory". This patch only changes the assumption that the bundled certificates will be there, and in case of failure will present the slight less unhelpful "Couldn't load system certificates".
There is still a failure case that I encountered where I have an empty /etc/ssl/certs directory, which will pass the check if the file exists, but will fail with the same "No such file or directory" error when actually used. This is not fixed in this patch.
Again, this only fixes the error message, not the actual problem that the certificates doesn't get loaded from the keychain when they aren't in /etc/ssl.