Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Curl can't find cainfo, when doing https request #1

Closed
bartv2 opened this issue Nov 13, 2018 · 6 comments
Closed

Curl can't find cainfo, when doing https request #1

bartv2 opened this issue Nov 13, 2018 · 6 comments

Comments

@bartv2
Copy link

bartv2 commented Nov 13, 2018

Disabling setting the CURLOPT_CAINFO option to null fixes this issue. Adding this option to the array only when ca_info is set should fix this issue.

@codemasher
Copy link
Member

Thank you for the info! I should state somewhere that ca certificate (or bundle) is necessary/mandatory for HTTPS. I'll also look into a workaround to not run into errors otherwise.

@codemasher
Copy link
Member

This is actually handled over here:

CURLOPT_CAINFO => is_file($this->options->ca_info) ? $this->options->ca_info : null,

I think the problem is rather that CURLOPT_SSL_VERIFYPEER is set to true by default, which then requires the cert- I think in an earlier version of the curl client i had this value depending on the existence of a cert.

codemasher added a commit that referenced this issue Nov 14, 2018
@bartv2
Copy link
Author

bartv2 commented Nov 14, 2018

The ca bundle is available on the system, and the connection works when i remove that line 121. I don't like your solution, i think only setting CURLOPT_CAINFO when $this->options->ca_info is a file would work better. When this is not specifically set the system default will be used.

@codemasher
Copy link
Member

codemasher commented Nov 14, 2018

Oh right, i didn't think about the system CA. But what would be a reliable way to check that? Or should i drop the check at all and leave the problem up to the user (which makes up 99% of SO questions about CURLOPT_SSL_VERIFYPEER)?

edit: brrrrr https://github.com/guzzle/guzzle/blob/master/src/functions.php#L160

@bartv2
Copy link
Author

bartv2 commented Nov 14, 2018

That function is only used in a very limited situation (streamHandler and php 5.?) For curl they do this: https://github.com/guzzle/guzzle/blob/master/src/Handler/CurlFactory.php#L326 I think that is the most flexible. Disabling CURLOPT_SSL_VERIFYPEER should be a last resort, maybe in the error message point to a checklist/steps to check/solve connection errors

codemasher added a commit that referenced this issue Nov 23, 2018
@bartv2
Copy link
Author

bartv2 commented Feb 22, 2019

Thanks, looks good

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants