Repository navigation
curl: apply --hsts to ipfs:// and ipns:// gateway requests - #23454
c8dhjp4tyv-bit wants to merge 3 commits into
Conversation
When an ipfs:// or ipns:// URL is rewritten to an http:// gateway URL, the transfer keeps the ipfs/ipns protocol token, and http_setopts() returned before CURLOPT_HSTS was set. The gateway request was then never upgraded to HTTPS, even when the gateway host had an HSTS entry. This has been the case since 8.14.0, when the HSTS setup moved into http_setopts(). Set CURLOPT_HSTS before the protocol check. Also stop adding the default port to the rewritten URL when the gateway URL has none, as the explicit :80 made the upgraded request go to port 80 instead of 443. Document that --hsts applies to IPFS gateway requests. Add test 465 to verify.
|
The CI failures look unrelated to this change:
This PR only touches the ipfs:// and ipns:// URL rewrite and the |
|
Analysis of PR #23454 at ae205e3c: Test ../../tests/http/test_60_h3_proxy.py::TestH3Proxy::test_60_12_quic_session_resumption failed, but it has been permanently failing lately, so it's probably NOT a fault of the PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Note that this CI job has had a number of other flaky tests recently (4, to be specific) so it may be that this failure is rather a systemic issue with this job and not with this specific PR. Test ../../tests/http/test_32_ftps_vsftpd.py::TestFtpsVsFTPD::test_32_04_download_10_parallel[data-1m] failed, but it has been 0.3% flaky lately, so it's probably NOT a fault of the PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Note that this CI job has had a number of other flaky tests recently (4, to be specific) so it may be that this failure is rather a systemic issue with this job and not with this specific PR. Test ../../tests/http/test_02_download.py::TestDownload::test_02_34_max_total_conns[False-0-h2] failed, but it has been 0.6% flaky lately, so it's probably NOT a fault of the PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Note that this CI job has had a number of other flaky tests recently (2, to be specific) so it may be that this failure is rather a systemic issue with this job and not with this specific PR. Generated by Testclutch |
Co-authored-by: Daniel Stenberg <daniel@haxx.se>
|
Thanks! |
When an ipfs:// or ipns:// URL is rewritten to an http:// gateway,
--hstsis not applied, so the request goes over plain HTTP even when the gateway host has an HSTS entry. A direct http:// request to the same host is upgraded.This changed in 8.14.0, when the HSTS setup moved into
http_setopts(), which returns early for anything that is not HTTP or HTTPS. The rewritten request keeps the ipfs/ipns protocol, so it never gets the HSTS cache. 8.13.0 upgrades these requests.The fix sets
CURLOPT_HSTSbefore that check. While testing I also found that the IPFS rewrite adds the default port to the URL even when the gateway URL has none, so the upgraded request went to port 80 instead of 443. It now only keeps a port the gateway URL sets.The
--hstsdocs now say it also applies to IPFS gateway requests.Test 465 covers it, and the existing IPFS, HSTS, source and documentation tests pass.