Skip to content

Commit

Permalink
LibGit2: use NetworkOptions to find CA root certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Nov 19, 2020
1 parent 359ca92 commit ff565c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
3 changes: 2 additions & 1 deletion stdlib/LibGit2/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ name = "LibGit2"
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[deps]
NetworkOptions = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Random", "Serialization", "Sockets"]
16 changes: 3 additions & 13 deletions stdlib/LibGit2/src/LibGit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module LibGit2
import Base: ==
using Base: something, notnothing
using Printf: @printf
import NetworkOptions

export with, GitRepo, GitConfig

Expand Down Expand Up @@ -983,19 +984,8 @@ end
end
end

# Look for OpenSSL env variable for CA bundle (linux only)
# windows and macOS use the OS native security backends
@static if Sys.islinux()
cert_loc = if "SSL_CERT_DIR" in keys(ENV)
ENV["SSL_CERT_DIR"]
elseif "SSL_CERT_FILE" in keys(ENV)
ENV["SSL_CERT_FILE"]
else
# If we have a bundled ca cert file, point libgit2 at that so SSL connections work.
abspath(ccall(:jl_get_julia_bindir, Any, ())::String, Base.DATAROOTDIR, "julia", "cert.pem")
end
set_ssl_cert_locations(cert_loc)
end
cert_loc = NetworkOptions.ca_roots()
cert_loc !== nothing && set_ssl_cert_locations(cert_loc)
end

function set_ssl_cert_locations(cert_loc)
Expand Down

0 comments on commit ff565c0

Please sign in to comment.