class ScanSSL::CertInfo
Public Class Methods
new(server, port)
click to toggle source
# File lib/scanssl/certInfo.rb, line 3 def initialize(server, port) @ssl_context = OpenSSL::SSL::SSLContext.new @cert_store = OpenSSL::X509::Store.new @cert_store.set_default_paths @ssl_context.cert_store = @cert_store @tcp_socket = TCPSocket.new(server, port) @socket_destination = OpenSSL::SSL::SSLSocket.new @tcp_socket, @ssl_context @socket_destination.connect end
Public Instance Methods
algorithm()
click to toggle source
# File lib/scanssl/certInfo.rb, line 33 def algorithm return cert.signature_algorithm end
cert()
click to toggle source
# File lib/scanssl/certInfo.rb, line 57 def cert return OpenSSL::X509::Certificate.new(@socket_destination.peer_cert) end
certprops()
click to toggle source
# File lib/scanssl/certInfo.rb, line 61 def certprops return OpenSSL::X509::Name.new(cert.issuer).to_a end
issuer()
click to toggle source
# File lib/scanssl/certInfo.rb, line 25 def issuer return certprops.select { |name, data, type| name == "O" }.first[1] end
key_size()
click to toggle source
# File lib/scanssl/certInfo.rb, line 37 def key_size begin key_size = OpenSSL::PKey::RSA.new(cert.public_key).to_text.match(/Public-Key: \((.*) bit/).to_a[1].strip.to_i if key_size.between?(1000, 2000) key_size = $1 elsif key_size > 2000 key_size = $1 else key_size = $1 end return key_size end rescue return "Problem with key_size" end
public_key()
click to toggle source
# File lib/scanssl/certInfo.rb, line 53 def public_key return cert.public_key end
subject()
click to toggle source
# File lib/scanssl/certInfo.rb, line 29 def subject return cert.subject end
valid?()
click to toggle source
# File lib/scanssl/certInfo.rb, line 13 def valid? return TRUTH_TABLE[(@socket_destination.verify_result == 0)] end
valid_from()
click to toggle source
# File lib/scanssl/certInfo.rb, line 17 def valid_from return cert.not_before end
valid_until()
click to toggle source
# File lib/scanssl/certInfo.rb, line 21 def valid_until return cert.not_after end