Skip to content

Commit 4e87640

Browse files
set TLS option CURLSSLOPT_REVOKE_BEST_EFFORT (#115)
The Windows native TLS backend (Schannel) makes synchronous certificate revocation checks against a CRL server. For users behind a firewall, this server may be unreachable, causing the TLS connection to fail. The CURLSSLOPT_REVOKE_BEST_EFFORT option addresses precisely this situation, configuring Schannel to make a best effort revocation check but allowing the connection if the CRL server cannot be reached, as long as the certificate isn't already known to be revoked. This behavior matches the default revocation checking behavior on macOS (asynchronous best effort) and is strictly more secure than Linux where no CRL checking is done. Since the typical advice in such situations is to disable TLS host verification entirely, this is an improvement in that with this option, so long as the client's system CA roots are configured correctly, host verification will work and at least local MITM attacks are prevented.
1 parent 6bddc0b commit 4e87640

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/Curl/Curl.jl

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ using LibCURL
2929
using LibCURL: curl_off_t
3030
# not exported: https://github.com/JuliaWeb/LibCURL.jl/issues/87
3131

32+
# constants that LibCURL should have but doesn't
33+
const CURLE_PEER_FAILED_VERIFICATION = 60
34+
const CURLSSLOPT_REVOKE_BEST_EFFORT = 1 << 3
35+
3236
using NetworkOptions
3337
using Base: preserve_handle, unpreserve_handle
3438

src/Curl/Easy.jl

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ function set_defaults(easy::Easy)
5151
setopt(easy, CURLOPT_USERAGENT, USER_AGENT)
5252
setopt(easy, CURLOPT_NETRC, CURL_NETRC_OPTIONAL)
5353
setopt(easy, CURLOPT_COOKIEFILE, "")
54+
setopt(easy, CURLOPT_SSL_OPTIONS, CURLSSLOPT_REVOKE_BEST_EFFORT)
5455

5556
# ssh-related options
5657
setopt(easy, CURLOPT_SSH_PRIVATE_KEYFILE, ssh_key_path())

test/runtests.jl

+1-4
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,7 @@ include("setup.jl")
414414
@testset "bad TLS is rejected" for url in urls
415415
resp = request(url, throw=false)
416416
@test resp isa RequestError
417-
# FIXME: we should use Curl.CURLE_PEER_FAILED_VERIFICATION
418-
# but LibCURL has gotten out of sync with curl and some
419-
# of the constants are no longer correct; this is one
420-
@test resp.code == 60
417+
@test resp.code == Curl.CURLE_PEER_FAILED_VERIFICATION
421418
end
422419
@testset "easy hook work-around" begin
423420
local url

0 commit comments

Comments
 (0)