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

#initializeContext

Returns a new instance of Context.



212
213
214
215
216
217
218
219
220
221
222
# File 'lib/puma/minissl.rb', line 212

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

#caObject

Returns the value of attribute ca.



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

def ca
  @ca
end

#certObject

Returns the value of attribute cert.



287
288
289
# File 'lib/puma/minissl.rb', line 287

def cert
  @cert
end

#cert_pemObject

Returns the value of attribute cert_pem.



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

def cert_pem
  @cert_pem
end

#cipher_suitesObject Also known as: ssl_cipher_list

Returns the value of attribute cipher_suites.



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

def cipher_suites
  @cipher_suites
end

#keyObject

non-jruby Context properties



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

def key
  @key
end

#key_password_commandObject

Returns the value of attribute key_password_command.



286
287
288
# File 'lib/puma/minissl.rb', line 286

def key_password_command
  @key_password_command
end

#key_pemObject

Returns the value of attribute key_pem.



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

def key_pem
  @key_pem
end

#keystoreObject

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



231
232
233
# File 'lib/puma/minissl.rb', line 231

def keystore
  @keystore
end

#keystore_passObject

Returns the value of attribute keystore_pass.



233
234
235
# File 'lib/puma/minissl.rb', line 233

def keystore_pass
  @keystore_pass
end

#keystore_typeObject

Returns the value of attribute keystore_type.



232
233
234
# File 'lib/puma/minissl.rb', line 232

def keystore_type
  @keystore_type
end

#no_tlsv1Object

Returns the value of attribute no_tlsv1.



210
211
212
# File 'lib/puma/minissl.rb', line 210

def no_tlsv1
  @no_tlsv1
end

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

disables TLSv1



373
374
375
376
# File 'lib/puma/minissl.rb', line 373

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

#no_tlsv1_1Object

Returns the value of attribute no_tlsv1_1.



210
211
212
# File 'lib/puma/minissl.rb', line 210

def no_tlsv1_1
  @no_tlsv1_1
end

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

disables TLSv1 and TLSv1.1. Overrides ‘#no_tlsv1=`



380
381
382
383
# File 'lib/puma/minissl.rb', line 380

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

#protocolsObject

Returns the value of attribute protocols.



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

def protocols
  @protocols
end

#reuseObject

Returns the value of attribute reuse.



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

def reuse
  @reuse
end

#reuse_cache_sizeObject (readonly)

Returns the value of attribute reuse_cache_size.



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

def reuse_cache_size
  @reuse_cache_size
end

#reuse_timeoutObject (readonly)

Returns the value of attribute reuse_timeout.



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

def reuse_timeout
  @reuse_timeout
end

#ssl_cipher_filterObject

Returns the value of attribute ssl_cipher_filter.



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

def ssl_cipher_filter
  @ssl_cipher_filter
end

#truststoreObject

Returns the value of attribute truststore.



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

def truststore
  @truststore
end

#truststore_passObject

Returns the value of attribute truststore_pass.



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

def truststore_pass
  @truststore_pass
end

#truststore_typeObject

Returns the value of attribute truststore_type.



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

def truststore_type
  @truststore_type
end

#verification_flagsObject

Returns the value of attribute verification_flags.



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

def verification_flags
  @verification_flags
end

#verify_modeObject

Returns the value of attribute verify_mode.



209
210
211
# File 'lib/puma/minissl.rb', line 209

def verify_mode
  @verify_mode
end

Instance Method Details

#checkObject



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

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

#check_file(file, desc) ⇒ Object

Raises:

  • (ArgumentError)


224
225
226
227
# File 'lib/puma/minissl.rb', line 224

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_passwordObject

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



331
332
333
334
335
336
337
338
339
# File 'lib/puma/minissl.rb', line 331

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