Class: Puma::MiniSSL::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/puma/minissl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Context

Returns a new instance of Context.



216
217
218
219
220
221
222
223
224
225
226
# File 'lib/puma/minissl.rb', line 216

def initialize
  @no_tlsv1   = false
  @no_tlsv1_1 = false
  @key = nil
  @cert = nil
  @key_pem = nil
  @cert_pem = nil
  @reuse = nil
  @reuse_cache_size = nil
  @reuse_timeout = nil
end

Instance Attribute Details

#ca ⇒ Object

Returns the value of attribute ca.



292
293
294
# File 'lib/puma/minissl.rb', line 292

def ca
  @ca
end

#cert ⇒ Object

Returns the value of attribute cert.



291
292
293
# File 'lib/puma/minissl.rb', line 291

def cert
  @cert
end

#cert_pem ⇒ Object

Returns the value of attribute cert_pem.



293
294
295
# File 'lib/puma/minissl.rb', line 293

def cert_pem
  @cert_pem
end

#cipher_suites ⇒ Object Also known as: ssl_cipher_list

Returns the value of attribute cipher_suites.



241
242
243
# File 'lib/puma/minissl.rb', line 241

def cipher_suites
  @cipher_suites
end

#key ⇒ Object

non-jruby Context properties



289
290
291
# File 'lib/puma/minissl.rb', line 289

def key
  @key
end

#key_password_command ⇒ Object

Returns the value of attribute key_password_command.



290
291
292
# File 'lib/puma/minissl.rb', line 290

def key_password_command
  @key_password_command
end

#key_pem ⇒ Object

Returns the value of attribute key_pem.



294
295
296
# File 'lib/puma/minissl.rb', line 294

def key_pem
  @key_pem
end

#keystore ⇒ Object

jruby-specific Context properties: java uses a keystore and password pair rather than a cert/key pair



235
236
237
# File 'lib/puma/minissl.rb', line 235

def keystore
  @keystore
end

#keystore_pass ⇒ Object

Returns the value of attribute keystore_pass.



237
238
239
# File 'lib/puma/minissl.rb', line 237

def keystore_pass
  @keystore_pass
end

#keystore_type ⇒ Object

Returns the value of attribute keystore_type.



236
237
238
# File 'lib/puma/minissl.rb', line 236

def keystore_type
  @keystore_type
end

#no_tlsv1 ⇒ Object

Returns the value of attribute no_tlsv1.



214
215
216
# File 'lib/puma/minissl.rb', line 214

def no_tlsv1
  @no_tlsv1
end

#no_tlsv1==(value) ⇒ Object (writeonly)

disables TLSv1



378
379
380
381
# File 'lib/puma/minissl.rb', line 378

def no_tlsv1=(tlsv1)
  raise ArgumentError, "Invalid value of no_tlsv1=" unless ['true', 'false', true, false].include?(tlsv1)
  @no_tlsv1 = tlsv1
end

#no_tlsv1_1 ⇒ Object

Returns the value of attribute no_tlsv1_1.



214
215
216
# File 'lib/puma/minissl.rb', line 214

def no_tlsv1_1
  @no_tlsv1_1
end

#no_tlsv1_1==(value) ⇒ Object (writeonly)

disables TLSv1 and TLSv1.1. Overrides #no_tlsv1=



385
386
387
388
# File 'lib/puma/minissl.rb', line 385

def no_tlsv1_1=(tlsv1_1)
  raise ArgumentError, "Invalid value of no_tlsv1_1=" unless ['true', 'false', true, false].include?(tlsv1_1)
  @no_tlsv1_1 = tlsv1_1
end

#protocols ⇒ Object

Returns the value of attribute protocols.



242
243
244
# File 'lib/puma/minissl.rb', line 242

def protocols
  @protocols
end

#reuse ⇒ Object

Returns the value of attribute reuse.



299
300
301
# File 'lib/puma/minissl.rb', line 299

def reuse
  @reuse
end

#reuse_cache_size ⇒ Object (readonly)

Returns the value of attribute reuse_cache_size.



299
300
301
# File 'lib/puma/minissl.rb', line 299

def reuse_cache_size
  @reuse_cache_size
end

#reuse_timeout ⇒ Object (readonly)

Returns the value of attribute reuse_timeout.



299
300
301
# File 'lib/puma/minissl.rb', line 299

def reuse_timeout
  @reuse_timeout
end

#ssl_cipher_filter ⇒ Object

Returns the value of attribute ssl_cipher_filter.



295
296
297
# File 'lib/puma/minissl.rb', line 295

def ssl_cipher_filter
  @ssl_cipher_filter
end

#ssl_ciphersuites ⇒ Object

Returns the value of attribute ssl_ciphersuites.



296
297
298
# File 'lib/puma/minissl.rb', line 296

def ssl_ciphersuites
  @ssl_ciphersuites
end

#truststore ⇒ Object

Returns the value of attribute truststore.



238
239
240
# File 'lib/puma/minissl.rb', line 238

def truststore
  @truststore
end

#truststore_pass ⇒ Object

Returns the value of attribute truststore_pass.



240
241
242
# File 'lib/puma/minissl.rb', line 240

def truststore_pass
  @truststore_pass
end

#truststore_type ⇒ Object

Returns the value of attribute truststore_type.



239
240
241
# File 'lib/puma/minissl.rb', line 239

def truststore_type
  @truststore_type
end

#verification_flags ⇒ Object

Returns the value of attribute verification_flags.



297
298
299
# File 'lib/puma/minissl.rb', line 297

def verification_flags
  @verification_flags
end

#verify_mode ⇒ Object

Returns the value of attribute verify_mode.



213
214
215
# File 'lib/puma/minissl.rb', line 213

def verify_mode
  @verify_mode
end

Instance Method Details

#check ⇒ Object



282
283
284
285
# File 'lib/puma/minissl.rb', line 282

def check
  raise "Keystore not configured" unless @keystore
  # @truststore defaults to @keystore due backwards compatibility
end

#check_file(file, desc) ⇒ Object

Raises:

  • (ArgumentError)


228
229
230
231
# File 'lib/puma/minissl.rb', line 228

def check_file(file, desc)
  raise ArgumentError, "#{desc} file '#{file}' does not exist" unless File.exist? file
  raise ArgumentError, "#{desc} file '#{file}' is not readable" unless File.readable? file
end

#key_password ⇒ Object

Executes the command to return the password needed to decrypt the key.



336
337
338
339
340
341
342
343
344
# File 'lib/puma/minissl.rb', line 336

def key_password
  raise "Key password command not configured" if @key_password_command.nil?

  stdout_str, stderr_str, status = Open3.capture3(@key_password_command)

  return stdout_str.chomp if status.success?

  raise "Key password failed with code #{status.exitstatus}: #{stderr_str}"
end