Class: WebHDFS::SSL
- Inherits:
-
Object
- Object
- WebHDFS::SSL
- Defined in:
- lib/webhdfs/ssl.rb
Overview
SSL class for http requests
Constant Summary collapse
- SSL_VERIFY_MODES =
[:none, :peer].freeze
Instance Attribute Summary collapse
-
#ca_file ⇒ Object
readonly
Returns the value of attribute ca_file.
-
#cert ⇒ Object
readonly
Returns the value of attribute cert.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#verify_mode ⇒ Object
Returns the value of attribute verify_mode.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#apply_to(connection) ⇒ Object
Apply ssl to a http connection.
-
#initialize(options = {}) ⇒ SSL
constructor
Constructor.
Constructor Details
#initialize(options = {}) ⇒ SSL
Constructor
11 12 13 14 15 16 17 |
# File 'lib/webhdfs/ssl.rb', line 11 def initialize( = {}) @ca_file = [:ca_file] self.verify_mode = [:verify_mode] @cert = [:cert] @key = [:key] @version = [:version] end |
Instance Attribute Details
#ca_file ⇒ Object (readonly)
Returns the value of attribute ca_file.
6 7 8 |
# File 'lib/webhdfs/ssl.rb', line 6 def ca_file @ca_file end |
#cert ⇒ Object (readonly)
Returns the value of attribute cert.
7 8 9 |
# File 'lib/webhdfs/ssl.rb', line 7 def cert @cert end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/webhdfs/ssl.rb', line 7 def key @key end |
#verify_mode ⇒ Object
Returns the value of attribute verify_mode.
6 7 8 |
# File 'lib/webhdfs/ssl.rb', line 6 def verify_mode @verify_mode end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
7 8 9 |
# File 'lib/webhdfs/ssl.rb', line 7 def version @version end |
Instance Method Details
#apply_to(connection) ⇒ Object
Apply ssl to a http connection
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/webhdfs/ssl.rb', line 28 def apply_to(connection) connection.use_ssl = true connection.ca_file = @ca_file if @ca_file if @verify_mode connection.verify_mode = case @verify_mode when :none then OpenSSL::SSL::VERIFY_NONE when :peer then OpenSSL::SSL::VERIFY_PEER end end connection.cert = @cert if @cert connection.key = @key if @key connection.ssl_version = @version if @version connection end |