| Summary: | Curl does not honour -capath | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | J.H.M. Dassen (Ray) <rdassen> | ||||
| Component: | curl | Assignee: | Kamil Dudka <kdudka> | ||||
| Status: | CLOSED ERRATA | QA Contact: | BaseOS QE Security Team <qe-baseos-security> | ||||
| Severity: | medium | Docs Contact: | |||||
| Priority: | medium | ||||||
| Version: | 6.0 | CC: | ebenes, ksrot, mhusnain, mvadkert, ovasik, prc, rbinkhor, rcritten | ||||
| Target Milestone: | rc | ||||||
| Target Release: | --- | ||||||
| Hardware: | All | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | Bug Fix | |||||
| Doc Text: |
libcurl ignored the CA path provided in CURLOPT_CAPATH and consequently curl ignored the "--capath" argument provided. This is fixed so that libcurl now uses the value provided with the the "--capath" argument.
|
Story Points: | --- | ||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2011-05-19 13:12:32 UTC | Type: | --- | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Bug Depends On: | |||||||
| Bug Blocks: | 627601 | ||||||
| Attachments: |
|
||||||
|
Description
J.H.M. Dassen (Ray)
2011-01-14 13:44:33 UTC
Does it connect successfully if you pass the CA certificate directly with --cacert ? Yes, it does. Then we need to improve the code that enumerates files in the given directory, and also update the man page -- it talks about OpenSSL hashing utility, which makes no sense for NSS powered curl. Created attachment 473876 [details]
proposed fix
Rob, could you please review the attached patch?
Comment on attachment 473876 [details]
proposed fix
I approve of the re-working of the code, the result is a lot more readable. I don't see any significant changes to the behavior though, how does this change make it work that the previous code didn't?
The fact that the flaw had not been visible (without gdb) actually forced me to make the code more readable. The main problem was the if/else sequence here:
if(!data->set.ssl.verifypeer)
/* skip the verifying of the peer */
;
else if(data->set.ssl.CAfile) {
...
}
else if(data->set.ssl.CApath) {
...
}
The legacy code treated the CAfile and CApath options mutually exclusive, which is wrong. CAfile fallbacks to the default CA bundle and therefore CApath had been never used.
Ray, does the patch solve the problem for you? Comment on attachment 473876 [details]
proposed fix
Ok, makes sense now.
(In reply to comment #8) > Ray, does the patch solve the problem for you? Yes, it does. Nice work! pushed upstream: https://github.com/bagder/curl/commit/fc77790 It seems that the fix have introduced bug 586355 again. The only diference is that curl doesn't timeout. I have tested bug 586355 with curl-7.19.7-18.el6.x86_64: :: [ PASS ] :: Running curl with --connect-timeout 7 * About to connect() to localhost port 4433 (#0) * Trying ::1... connected * Connected to localhost (::1) port 4433 (#0) * Initializing NSS with certpath: /etc/pki/nssdb * CAfile: ./myca.crt CApath: none * NSS error -5990 * Closing connection #0 * SSL connect error curl: (35) SSL connect error :: [ PASS ] :: File 'curl.out' should contain 'SSL connect error' :: [ PASS ] :: Save time after running curl :: [06:05:36] :: curl was waiting 7 seconds ..and with curl-7.19.7-19.el6.x86_64 that adds: - fix handling of CURLOPT_CAPATH in libcurl (#669702) :: [ FAIL ] :: Running curl with --connect-timeout 7 (Expected 28,35, got 56) * About to connect() to localhost port 4433 (#0) * Trying ::1... connected * Connected to localhost (::1) port 4433 (#0) * Initializing NSS with certpath: /etc/pki/nssdb * CAfile: ./myca.crt CApath: none * NSS error -5990 > GET /index.html HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.12.9.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2 > Host: localhost:4433 > Accept: */* > % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:13 --:--:-- 0* Closing connection #0 * Failure when receiving data from the peer curl: (56) Failure when receiving data from the peer :: [ FAIL ] :: File 'curl.out' should contain 'SSL connect error' :: [ PASS ] :: Save time after running curl :: [06:07:42] :: curl was waiting 181 seconds After 180 seconds the peer (openssl server) has been terminated, therefore the failure. Shortened test scenario is at https://bugzilla.redhat.com/show_bug.cgi?id=586355#c6 Ups, I tried ^ ^ more time, in case of 180 second limit also the Time Spent column contains 0:03:00. Perhaps the amount of time should be updated? The loading of CA certs may take some time (and memory) since the PEM reader module is not much optimized yet... Which amount of time do you mean exactly? Karel says that the new curl was waiting for 180s and it didn't even then timeout. (In reply to comment #16) > :: [ FAIL ] :: Running curl with --connect-timeout 7 (Expected 28,35, got > 56) > * About to connect() to localhost port 4433 (#0) > * Trying ::1... connected > * Connected to localhost (::1) port 4433 (#0) > * Initializing NSS with certpath: /etc/pki/nssdb > * CAfile: ./myca.crt > CApath: none > * NSS error -5990 So far so good, -5990 means PR_IO_TIMEOUT_ERROR. > > GET /index.html HTTP/1.1 > > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.12.9.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2 > > Host: localhost:4433 > > Accept: */* This ^^^ looks suspicious. curl is talking to an already dead connection. The patch is indeed broken. Thanks for catching it. The 'error' variable is mistakenly nullified at this point: https://github.com/bagder/curl/commit/fc77790#L3R1302 We need to improve the patch such that 'error' stays set to CURLE_SSL_CONNECT_ERROR. (In reply to comment #21) s/error/curlerr/ pushed a fix upstream: https://github.com/bagder/curl/commit/7aa2d10
Technical note added. If any revisions are required, please edit the "Technical Notes" field
accordingly. All revisions will be proofread by the Engineering Content Services team.
New Contents:
libcurl ignored the CA path provided in CURLOPT_CAPATH and consequently curl ignored the "--capath" argument provided. This is fixed so that libcurl now uses the value provided with the the "--capath" argument.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2011-0573.html |