Class: BetterCap::Proxy::HTTP::SSL::Fetcher

Inherits:
Net::HTTP
  • Object
show all
Defined in:
lib/bettercap/proxy/http/ssl/authority.rb

Overview

Simple wrapper class used to fetch a server HTTPS certificate.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#certificateObject

The server HTTPS certificate.



22
23
24
# File 'lib/bettercap/proxy/http/ssl/authority.rb', line 22

def certificate
  @certificate
end

Class Method Details

.fetch(hostname, port) ⇒ Object

Fetch the HTTPS certificate of hostname:port.



29
30
31
32
33
34
35
36
# File 'lib/bettercap/proxy/http/ssl/authority.rb', line 29

def self.fetch( hostname, port )
  http             = self.new( hostname, port )
  http.use_ssl     = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE

  http.head("/")
  http.certificate
end

Instance Method Details

#on_connectObject

Overridden from Net::HTTP in order to save the peer certificate before the connection is closed.



25
26
27
# File 'lib/bettercap/proxy/http/ssl/authority.rb', line 25

def on_connect
  @certificate = peer_cert
end