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.



258
259
260
261
262
263
264
265
266
267
268
# File 'lib/puma/minissl.rb', line 258

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.



334
335
336
# File 'lib/puma/minissl.rb', line 334

def ca
  @ca
end

#cert ⇒ Object

Returns the value of attribute cert.



333
334
335
# File 'lib/puma/minissl.rb', line 333

def cert
  @cert
end

#cert_pem ⇒ Object

Returns the value of attribute cert_pem.



335
336
337
# File 'lib/puma/minissl.rb', line 335

def cert_pem
  @cert_pem
end

#cipher_suites ⇒ Object Also known as: ssl_cipher_list

Returns the value of attribute cipher_suites.



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

def cipher_suites
  @cipher_suites
end

#key ⇒ Object

non-jruby Context properties



331
332
333
# File 'lib/puma/minissl.rb', line 331

def key
  @key
end

#key_password_command ⇒ Object

Returns the value of attribute key_password_command.



332
333
334
# File 'lib/puma/minissl.rb', line 332

def key_password_command
  @key_password_command
end

#key_pem ⇒ Object

Returns the value of attribute key_pem.



336
337
338
# File 'lib/puma/minissl.rb', line 336

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



277
278
279
# File 'lib/puma/minissl.rb', line 277

def keystore
  @keystore
end

#keystore_pass ⇒ Object

Returns the value of attribute keystore_pass.



279
280
281
# File 'lib/puma/minissl.rb', line 279

def keystore_pass
  @keystore_pass
end

#keystore_type ⇒ Object

Returns the value of attribute keystore_type.



278
279
280
# File 'lib/puma/minissl.rb', line 278

def keystore_type
  @keystore_type
end

#no_tlsv1 ⇒ Object

Returns the value of attribute no_tlsv1.



256
257
258
# File 'lib/puma/minissl.rb', line 256

def no_tlsv1
  @no_tlsv1
end

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

disables TLSv1



420
421
422
423
# File 'lib/puma/minissl.rb', line 420

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.



256
257
258
# File 'lib/puma/minissl.rb', line 256

def no_tlsv1_1
  @no_tlsv1_1
end

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

disables TLSv1 and TLSv1.1. Overrides #no_tlsv1=



427
428
429
430
# File 'lib/puma/minissl.rb', line 427

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.



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

def protocols
  @protocols
end

#reuse ⇒ Object

Returns the value of attribute reuse.



341
342
343
# File 'lib/puma/minissl.rb', line 341

def reuse
  @reuse
end

#reuse_cache_size ⇒ Object (readonly)

Returns the value of attribute reuse_cache_size.



341
342
343
# File 'lib/puma/minissl.rb', line 341

def reuse_cache_size
  @reuse_cache_size
end

#reuse_timeout ⇒ Object (readonly)

Returns the value of attribute reuse_timeout.



341
342
343
# File 'lib/puma/minissl.rb', line 341

def reuse_timeout
  @reuse_timeout
end

#ssl_cipher_filter ⇒ Object

Returns the value of attribute ssl_cipher_filter.



337
338
339
# File 'lib/puma/minissl.rb', line 337

def ssl_cipher_filter
  @ssl_cipher_filter
end

#ssl_ciphersuites ⇒ Object

Returns the value of attribute ssl_ciphersuites.



338
339
340
# File 'lib/puma/minissl.rb', line 338

def ssl_ciphersuites
  @ssl_ciphersuites
end

#truststore ⇒ Object

Returns the value of attribute truststore.



280
281
282
# File 'lib/puma/minissl.rb', line 280

def truststore
  @truststore
end

#truststore_pass ⇒ Object

Returns the value of attribute truststore_pass.



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

def truststore_pass
  @truststore_pass
end

#truststore_type ⇒ Object

Returns the value of attribute truststore_type.



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

def truststore_type
  @truststore_type
end

#verification_flags ⇒ Object

Returns the value of attribute verification_flags.



339
340
341
# File 'lib/puma/minissl.rb', line 339

def verification_flags
  @verification_flags
end

#verify_mode ⇒ Object

Returns the value of attribute verify_mode.



255
256
257
# File 'lib/puma/minissl.rb', line 255

def verify_mode
  @verify_mode
end

Instance Method Details

#check ⇒ Object



324
325
326
327
# File 'lib/puma/minissl.rb', line 324

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

#check_file(file, desc) ⇒ Object

Raises:

  • (ArgumentError)


270
271
272
273
# File 'lib/puma/minissl.rb', line 270

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.



378
379
380
381
382
383
384
385
386
# File 'lib/puma/minissl.rb', line 378

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