8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/rubygems_pq_tls_policy/diagnostic.rb', line 8
def report(io = $stdout)
require "openssl"
require "rubygems/request"
io.puts "ruby=#{RUBY_DESCRIPTION}"
io.puts "engine=#{defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'}"
io.puts "openssl=#{defined?(OpenSSL::OPENSSL_VERSION) ? OpenSSL::OPENSSL_VERSION : 'unavailable'}"
io.puts "openssl_library=#{defined?(OpenSSL::OPENSSL_LIBRARY_VERSION) ? OpenSSL::OPENSSL_LIBRARY_VERSION : 'unavailable'}"
socket = defined?(OpenSSL::SSL::SSLSocket) ? OpenSSL::SSL::SSLSocket : nil
context = defined?(OpenSSL::SSL::SSLContext) ? OpenSSL::SSL::SSLContext.new : nil
https_pool = defined?(Gem::Request::HTTPSPool) ? Gem::Request::HTTPSPool : nil
http_pool = defined?(Gem::Request::HTTPPool) ? Gem::Request::HTTPPool : nil
io.puts "sslsocket=#{socket ? 'available' : 'unavailable'}"
io.puts "group=#{socket&.method_defined?(:group) ? 'available' : 'unavailable'}"
io.puts "rubygems_https_pool=#{https_pool&.private_method_defined?(:setup_connection) ? 'available' : 'unavailable'}"
io.puts "rubygems_http_pool=#{http_pool&.private_method_defined?(:setup_connection) ? 'available' : 'unavailable'}"
io.puts "ssl_context_groups_setter=#{context&.respond_to?(:groups=) ? 'available' : 'unavailable'}"
policy_runtime = Gem::PqTlsPolicy.openssl_runtime_version_at_least?(3, 5, 0) &&
socket&.method_defined?(:group) &&
https_pool&.private_method_defined?(:setup_connection) &&
http_pool&.private_method_defined?(:setup_connection)
io.puts "pq_tls_policy_runtime=#{policy_runtime ? 'available' : 'unavailable'}"
true
rescue LoadError => e
io.puts "openssl=unavailable"
io.puts "error=#{e.class}: #{e.message}"
false
end
|