Class: ThumbPrint
- Inherits:
-
Object
- Object
- ThumbPrint
- Defined in:
- lib/VMwareWebService/thumb_print.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cert ⇒ Object
Returns the value of attribute cert.
-
#der_thumb_print ⇒ Object
readonly
Returns the value of attribute der_thumb_print.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#thumb_print ⇒ Object
readonly
Returns the value of attribute thumb_print.
-
#x509_cert ⇒ Object
readonly
Returns the value of attribute x509_cert.
Instance Method Summary collapse
- #http_request ⇒ Object
-
#initialize(host) ⇒ ThumbPrint
constructor
A new instance of ThumbPrint.
- #to_sha1 ⇒ Object
Constructor Details
#initialize(host) ⇒ ThumbPrint
Returns a new instance of ThumbPrint.
8 9 10 11 12 13 14 |
# File 'lib/VMwareWebService/thumb_print.rb', line 8 def initialize(host) $log.info "ThumbPrint.initialize(#{host})" if $log @host = host @cert = nil uri http_request end |
Instance Attribute Details
#cert ⇒ Object
Returns the value of attribute cert.
6 7 8 |
# File 'lib/VMwareWebService/thumb_print.rb', line 6 def cert @cert end |
#der_thumb_print ⇒ Object (readonly)
Returns the value of attribute der_thumb_print.
5 6 7 |
# File 'lib/VMwareWebService/thumb_print.rb', line 5 def der_thumb_print @der_thumb_print end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/VMwareWebService/thumb_print.rb', line 5 def host @host end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
5 6 7 |
# File 'lib/VMwareWebService/thumb_print.rb', line 5 def http @http end |
#thumb_print ⇒ Object (readonly)
Returns the value of attribute thumb_print.
5 6 7 |
# File 'lib/VMwareWebService/thumb_print.rb', line 5 def thumb_print @thumb_print end |
#x509_cert ⇒ Object (readonly)
Returns the value of attribute x509_cert.
5 6 7 |
# File 'lib/VMwareWebService/thumb_print.rb', line 5 def x509_cert @x509_cert end |
Instance Method Details
#http_request ⇒ Object
16 17 18 19 20 |
# File 'lib/VMwareWebService/thumb_print.rb', line 16 def http_request @http = Net::HTTP.new(@uri.host, @uri.port) @http.use_ssl = true @http.verify_mode = OpenSSL::SSL::VERIFY_NONE end |
#to_sha1 ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/VMwareWebService/thumb_print.rb', line 22 def to_sha1 @cert = to_cert if @cert.nil? $log.info "ThumbPrint.to_sha1 for host #{@host}" if $log raise "Invalid Certificate" if @cert.nil? @x509_cert = OpenSSL::X509::Certificate.new(@cert) @der_thumb_print = OpenSSL::Digest::SHA1.new(@x509_cert.to_der).to_s @thumb_print = @der_thumb_print.scan(/../).collect(&:upcase).join(":") $log.info "ThumbPrint.to_sha1 for host #{@host} is #{@thumb_print}" if $log @thumb_print end |