Module: Aspera::SSL

Defined in:
lib/aspera/ssl.rb

Overview

Give possibility to globally override SSL options

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.extra_options ⇒ Object (readonly)

Returns the value of attribute extra_options.



13
14
15
# File 'lib/aspera/ssl.rb', line 13

def extra_options
  @extra_options
end

Class Method Details

.option_list=(options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/aspera/ssl.rb', line 15

def option_list=(options)
  Aspera.assert_type(options, Array) { 'ssl_options' }
  options.each do |opt|
    Aspera.assert_type(opt, String, Integer) { 'Expected String or Integer in ssl_options' }
    case opt
    when Integer
      @extra_options = opt
    when String
      name = "OP_#{opt.start_with?('-') ? opt[1..] : opt}".upcase
      Aspera.assert(OpenSSL::SSL.const_defined?(name), type: Cli::BadArgument) { "Unknown ssl_option: #{name}, use one of: #{OpenSSL::SSL.constants.grep(/^OP_/).map { |c| c.to_s.sub(/^OP_/, '') }.join(', ')}" }
      if opt.start_with?('-')
        @extra_options &= ~OpenSSL::SSL.const_get(name)
      else
        @extra_options |= OpenSSL::SSL.const_get(name)
      end
    end
  end
end

Instance Method Details

#set_params(params = {}) ⇒ Object



34
35
36
37
38
# File 'lib/aspera/ssl.rb', line 34

def set_params(params = {})
  super(params)
  self.options = Aspera::SSL.extra_options unless Aspera::SSL.extra_options.nil?
  self
end