Class: Snackhack2::SSLCert
- Inherits:
-
Object
- Object
- Snackhack2::SSLCert
- Defined in:
- lib/snackhack2/SSL.rb
Instance Attribute Summary collapse
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
- #get_cert ⇒ Object
-
#initialize ⇒ SSLCert
constructor
A new instance of SSLCert.
Constructor Details
#initialize ⇒ SSLCert
Returns a new instance of SSLCert.
7 8 9 |
# File 'lib/snackhack2/SSL.rb', line 7 def initialize @site = site end |
Instance Attribute Details
#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 ⇒ Object
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 |