Class: CacertApiRequester

Inherits:
Object
  • Object
show all
Defined in:
lib/cacert-rq.rb

Instance Method Summary collapse

Constructor Details

#initialize(informations) ⇒ CacertApiRequester

Returns a new instance of CacertApiRequester.



2
3
4
5
6
7
8
9
10
11
# File 'lib/cacert-rq.rb', line 2

def initialize(informations)
  @username = informations[:username]
  @password = informations[:password]
  @ca_file  = informations[:ca_file]
  @email    = email_to_str(informations[:email])
  @name     = CGI::escape(informations[:name])
  @codesign = informations[:codesign] ? 1 : 0
  @action   = which_action(informations[:action])
  @csr      = informations[:csr] ? CGI::escapte(informations[:csr]) : ""
end

Instance Method Details

#requestObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cacert-rq.rb', line 13

def request
  http = Net::HTTP.new("www.cacert.org", 443)
  req = Net::HTTP::Get.new(@action)
  http.use_ssl = true
  if  !@ca_file.nil? and !@ca_file.empty? # Force SSL peer verification
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER
    http.ca_file = @ca_file
  end
  reponse = http.request(req)
  p reponse.body
end