Class: Sophos::SG::REST::HTTP
- Inherits:
-
Net::HTTP
- Object
- Net::HTTP
- Sophos::SG::REST::HTTP
- Defined in:
- lib/sophos/sg/rest/http.rb
Overview
Copyright 2016 Sophos Technology GmbH. All rights reserved. See the LICENSE.txt file for details. Authors: Vincent Landgraf
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url, options = {}) ⇒ HTTP
constructor
A new instance of HTTP.
Constructor Details
#initialize(url, options = {}) ⇒ HTTP
Returns a new instance of HTTP.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sophos/sg/rest/http.rb', line 8 def initialize(url, = {}) @url = URI(url) super(@url.host, @url.port) if @url.scheme == 'https' self.use_ssl = true self.verify_mode = OpenSSL::SSL::VERIFY_PEER self.verify_callback = lambda do |preverify_ok, ssl_context| if [:fingerprint] # check if the fingerprint is matching (don't respect the chain) fingerprint = [:fingerprint].gsub(/\s|:/, '').downcase ssl_context.chain.each do |cert| if fingerprint == OpenSSL::Digest::SHA1.new(cert.to_der).to_s return true end end false else # if the certificate is valid and no fingerprint is passed the # certificate chain result is determining preverify_ok end end end end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/sophos/sg/rest/http.rb', line 6 def url @url end |