class Prof::SSL::Check
Attributes
proxy[R]
url[R]
Public Class Methods
new(url, proxy=nil)
click to toggle source
# File lib/prof/ssl/check.rb, line 22 def initialize(url, proxy=nil) @url = URI.parse(url) @proxy = proxy || OpenStruct.new(:http_host => nil, :http_address => nil) end
Public Instance Methods
protocols()
click to toggle source
# File lib/prof/ssl/check.rb, line 31 def protocols @protocols ||= OpenSSL::SSL::SSLContext::METHODS.reject { |m| /_(client|server)$/ =~ m.to_s }.reject { |m| m == :SSLv2 || m == :SSLv3 } end
results()
click to toggle source
# File lib/prof/ssl/check.rb, line 27 def results Results.new(protocols.map { |protocol| check_protocol(protocol) }) end
Private Instance Methods
check_cipher(protocol, cipher_name)
click to toggle source
# File lib/prof/ssl/check.rb, line 59 def check_cipher(protocol, cipher_name) request = http_request request.ssl_version = protocol request.ciphers = cipher_name begin request.get('/') Result.new(protocol, cipher_name, true) rescue OpenSSL::SSL::SSLError, Errno::ECONNRESET Result.new(protocol, cipher_name, false) end end
check_protocol(protocol)
click to toggle source
# File lib/prof/ssl/check.rb, line 51 def check_protocol(protocol) cipher_names(protocol).map { |cipher_name| check_cipher(protocol, cipher_name) } end
cipher_names(protocol)
click to toggle source
# File lib/prof/ssl/check.rb, line 55 def cipher_names(protocol) OpenSSL::SSL::SSLContext.new(protocol).ciphers.map(&:first) end
host()
click to toggle source
# File lib/prof/ssl/check.rb, line 47 def host url.host end
http_request()
click to toggle source
# File lib/prof/ssl/check.rb, line 71 def http_request request = Net::HTTP.new(host, port, proxy.http_host, proxy.http_port) request.use_ssl = true request.verify_mode = OpenSSL::SSL::VERIFY_NONE request end
port()
click to toggle source
# File lib/prof/ssl/check.rb, line 43 def port url.port end