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

Fails properly when system certificates can't be found #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ulrikdamm
Copy link

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.

@tanner0101 tanner0101 added this to the 2.1.3 milestone Feb 15, 2018
@tanner0101 tanner0101 added the bug label Feb 15, 2018
Copy link
Contributor

@tanner0101 tanner0101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this fix!

Unfortunately we can't merge any breaking changes into the 2.x release. However, if you update this PR to keep public API intact I will happily accept.

}
}

extension Certificates {
public static var openbsd: Certificates {
public static var openbsd: Certificates? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't change this API since it's public (that would require a major revision).

@tanner0101
Copy link
Contributor

Version 3 of this package is now at master. This PR will need to be re-opened against the latest 2.x tag.

@Joannis Joannis removed their assignment Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants