Skip to content

Commit 0bd3345

Browse files
also reset SYSTEM_CA_ROOTS and ENV_HOST_PATTERN_CACHE from __init__ (#35)
1 parent aab83e5 commit 0bd3345

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/NetworkOptions.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ include("ca_roots.jl")
44
include("ssh_options.jl")
55
include("verify_host.jl")
66

7+
function __init__()
8+
SYSTEM_CA_ROOTS[] = nothing
9+
BUNDLED_KNOWN_HOSTS_FILE[] = nothing
10+
empty!(ENV_HOST_PATTERN_CACHE)
11+
end
12+
713
end # module

src/ca_roots.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const BSD_CA_ROOTS = [
7474
]
7575

7676
const SYSTEM_CA_ROOTS_LOCK = ReentrantLock()
77-
const SYSTEM_CA_ROOTS = Ref{String}()
77+
const SYSTEM_CA_ROOTS = Ref{Union{Nothing, String}}(nothing)
7878

7979
const BEGIN_CERT_REGULAR = "-----BEGIN CERTIFICATE-----"
8080
const BEGIN_CERT_OPENSSL = "-----BEGIN TRUSTED CERTIFICATE-----"
@@ -84,7 +84,7 @@ NetworkOptions could only find OpenSSL-specific TLS certificates which cannot be
8484

8585
function system_ca_roots()
8686
lock(SYSTEM_CA_ROOTS_LOCK) do
87-
isassigned(SYSTEM_CA_ROOTS) && return # from lock()
87+
SYSTEM_CA_ROOTS[] !== nothing && return # from lock()
8888
search_path = Sys.islinux() ? LINUX_CA_ROOTS :
8989
Sys.isbsd() && !Sys.isapple() ? BSD_CA_ROOTS : String[]
9090
openssl_only = false

src/ssh_options.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,6 @@ function bundled_known_hosts()
160160
end
161161
end
162162

163-
function __init__()
164-
# Reset in case we serialized a value here.
165-
lock(BUNDLED_KNOWN_HOSTS_LOCK) do
166-
BUNDLED_KNOWN_HOSTS_FILE[] = nothing
167-
end
168-
end
169-
170163
const BUNDLED_KNOWN_HOSTS = """
171164
github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
172165
github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl

0 commit comments

Comments
 (0)