Class: Snackhack2::SSLCert

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ SSLCert

Returns a new instance of SSLCert.



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

def initialize
	@site = site
	@file_save = false
end

Instance Attribute Details

#file_save ⇒ Object

Returns the value of attribute file_save.



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

def file_save
  @file_save
end

#site ⇒ Object

Returns the value of attribute site.



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

def site
  @site
end

Instance Method Details

#get_cert(print_status: false) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/snackhack2/SSL.rb', line 11

def get_cert(print_status: false)
	save_txt_file = ''
	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
		if @file_save
			save_txt_file += cert.serial
		else 
			if print_status
				puts cert.serial
			else
				return cert.serial
			end
		end
	rescue OpenSSL::SSL::SSLError,Net::OpenTimeout, Errno::EHOSTUNREACH
	end
Snackhack2.file_save(@site, 'ssl', save_txt_file) if @file_save
end