@@ -452,26 +452,24 @@ end
452452
453453const nosslconfig = SSLConfig ()
454454const nosslcontext = Ref {OpenSSL.SSLContext} ()
455- default_sslconfig = nothing
456- noverify_sslconfig = nothing
455+ const default_sslconfig = Ref {Union{Nothing, SSLConfig}} ( nothing )
456+ const noverify_sslconfig = Ref {Union{Nothing, SSLConfig}} ( nothing )
457457
458458function global_sslconfig (require_ssl_verification:: Bool ):: SSLConfig
459- global default_sslconfig
460- global noverify_sslconfig
461- if default_sslconfig === nothing
462- default_sslconfig = SSLConfig (true )
463- noverify_sslconfig = SSLConfig (false )
459+ if default_sslconfig[] === nothing
460+ default_sslconfig[] = SSLConfig (true )
461+ noverify_sslconfig[] = SSLConfig (false )
464462 end
465463 if haskey (ENV , " HTTP_CA_BUNDLE" )
466- MbedTLS. ca_chain! (default_sslconfig, MbedTLS. crt_parse (read (ENV [" HTTP_CA_BUNDLE" ], String)))
464+ MbedTLS. ca_chain! (default_sslconfig[] , MbedTLS. crt_parse (read (ENV [" HTTP_CA_BUNDLE" ], String)))
467465 elseif haskey (ENV , " CURL_CA_BUNDLE" )
468- MbedTLS. ca_chain! (default_sslconfig, MbedTLS. crt_parse (read (ENV [" CURL_CA_BUNDLE" ], String)))
466+ MbedTLS. ca_chain! (default_sslconfig[] , MbedTLS. crt_parse (read (ENV [" CURL_CA_BUNDLE" ], String)))
469467 end
470- return require_ssl_verification ? default_sslconfig : noverify_sslconfig
468+ return require_ssl_verification ? default_sslconfig[] : noverify_sslconfig[]
471469end
472470
473471function global_sslcontext ():: OpenSSL.SSLContext
474- if isdefined (OpenSSL, :ca_chain! )
472+ @static if isdefined (OpenSSL, :ca_chain! )
475473 if haskey (ENV , " HTTP_CA_BUNDLE" )
476474 sslcontext = OpenSSL. SSLContext (OpenSSL. TLSClientMethod ())
477475 OpenSSL. ca_chain! (sslcontext, ENV [" HTTP_CA_BUNDLE" ])
0 commit comments