Class: Snackhack2::SSLCert

Inherits:
Object
  • Object
show all
Defined in:
lib/snackhack2/SSL.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSSLCert

Returns a new instance of SSLCert.



7
8
9
# File 'lib/snackhack2/SSL.rb', line 7

def initialize
	@site = site
end

Instance Attribute Details

#siteObject

Returns the value of attribute site.



5
6
7
# File 'lib/snackhack2/SSL.rb', line 5

def site
  @site
end

Instance Method Details

#get_certObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/snackhack2/SSL.rb', line 10

def get_cert
	begin
		if @site.downcase.include?("https://")
			@site = @site.downcase.gsub("https://", "")
		end
		uri = URI::HTTPS.build(host: @site)
		response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true)
		cert = response.peer_cert
		puts cert.serial
	rescue OpenSSL::SSL::SSLError,Net::OpenTimeout, Errno::EHOSTUNREACH
	end
end