Skip to content

Commit e22219f

Browse files
tests: skip wrong host test for SSL_NO_VERIFY (fix #139) (#140)
Since #114, we only turn off peer verification, not host verification when the `SSL_NO_VERIFY` variables are set. This means that the last set of tests in the "SSL no verify override" testset *should* fail for `wrong.host.badssl.com`. That is not what I was seeing, however — the test was still passing — which I found puzzling but just moved on with my life at the time. It turns out that the test *does* fail if libcurl is build with OpenSSL. Since whether the test passes or not for that host depends on how things are built, this change simply skips the test (by popping the URL from the set of tested URLS for that testset). The tests above that which use the easy hook mechanism are fixed in a different way: for those I made the hook disable both host and peer verification, which should fix the tests for any bad host including when the server sends the wrong host name.
1 parent 25f7af3 commit e22219f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/runtests.jl

+7-2
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ include("setup.jl")
426426

427427
@testset "bad TLS" begin
428428
urls = [
429-
"https://wrong.host.badssl.com"
430429
"https://untrusted-root.badssl.com"
430+
"https://wrong.host.badssl.com"
431431
]
432432
@testset "bad TLS is rejected" for url in urls
433433
resp = request(url, throw=false)
@@ -437,7 +437,9 @@ include("setup.jl")
437437
@testset "easy hook work-around" begin
438438
local url
439439
easy_hook = (easy, info) -> begin
440-
Curl.set_ssl_verify(easy, false)
440+
# don't verify anything (this disables SNI also)
441+
Curl.setopt(easy, Curl.CURLOPT_SSL_VERIFYPEER, false)
442+
Curl.setopt(easy, Curl.CURLOPT_SSL_VERIFYHOST, false)
441443
@test info.url == url
442444
end
443445
# downloader-specific easy hook
@@ -460,6 +462,9 @@ include("setup.jl")
460462
Downloads.EASY_HOOK[] = nothing
461463
end
462464
ENV["JULIA_SSL_NO_VERIFY_HOSTS"] = "**.badssl.com"
465+
# wrong host *should* still fail, but may not due
466+
# to libcurl bugs when using non-OpenSSL backends:
467+
pop!(urls) # <= skip wrong host URL entirely here
463468
@testset "SSL no verify override" for url in urls
464469
resp = request(url, throw=false)
465470
@test resp isa Response

0 commit comments

Comments
 (0)