Skip to content

Commit 818cd12

Browse files
unverified HTTPS: don't set CURLOPT_SSL_VERIFYHOST=0
In https://curl.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html under "Limitations", it is documented that when `CURLOPT_SSL_VERIFYHOST` is set to zero this also turns off SNI (Server Name Indication): > Secure Transport: If verify value is 0, then SNI is also disabled. SNI > is a TLS extension that sends the hostname to the server. The server > may use that information to do such things as sending back a specific > certificate for the hostname, or forwarding the request to a specific > origin server. Some hostnames may be inaccessible if SNI is not sent. Since SNI is required to make requests to some HTTPS servers, disabling SNI can break things. This change leaves host verification on and only turns peer verification off (i.e. CA chain checking). I have yet to find an example where turning host verification off is necessary. Closes #113. (cherry picked from commit 86e52d7)
1 parent a148880 commit 818cd12

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Curl/Easy.jl

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ set_url(easy::Easy, url::AbstractString) = set_url(easy, String(url))
7373

7474
function set_ssl_verify(easy::Easy, verify::Bool)
7575
setopt(easy, CURLOPT_SSL_VERIFYPEER, verify)
76-
setopt(easy, CURLOPT_SSL_VERIFYHOST, verify*2)
7776
end
7877

7978
function set_ssh_verify(easy::Easy, verify::Bool)

test/runtests.jl

+13
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,19 @@ include("setup.jl")
410410
delete!(ENV, "JULIA_SSL_NO_VERIFY_HOSTS")
411411
end
412412

413+
@testset "SNI required" begin
414+
url = "https://juliahub.com" # anything served by CloudFront
415+
# secure verified host request
416+
resp = request(url, throw=false, downloader=Downloader())
417+
@test resp isa Response
418+
@test resp.status == 200
419+
# insecure unverified host request
420+
ENV["JULIA_SSL_NO_VERIFY_HOSTS"] = "**"
421+
resp = request(url, throw=false, downloader=Downloader())
422+
@test resp isa Response
423+
@test resp.status == 200
424+
end
425+
413426
if save_env !== nothing
414427
ENV["JULIA_SSL_NO_VERIFY_HOSTS"] = save_env
415428
else

0 commit comments

Comments
 (0)