Browse Source

Better way to manager TLS methods as symbol

new-scoring
aeris 6 years ago
parent
commit
4fa17e724f
  1. 3
      lib/cryptcheck/tls/cipher.rb
  2. 10
      lib/cryptcheck/tls/server.rb

3
lib/cryptcheck/tls/cipher.rb

@ -273,8 +273,9 @@ module CryptCheck
ALL = 'ALL:COMPLEMENTOFALL'
SUPPORTED = Method.collect do |m|
context = ::OpenSSL::SSL::SSLContext.new m.name
context = ::OpenSSL::SSL::SSLContext.new m.to_sym
context.ciphers = ALL
[m, context.ciphers.collect { |c| Cipher.new m, c.first }.sort ]
end.to_h.freeze
end

10
lib/cryptcheck/tls/server.rb

@ -28,7 +28,7 @@ module CryptCheck
class ConnectionError < ::StandardError
end
attr_reader :certs, :keys, :dh, :supported_methods, :supported_curves, :curves_preference
attr_reader :certs, :keys, :dh, :supported_methods, :supported_ciphers, :supported_curves, :curves_preference
def initialize(hostname, family, ip, port)
@hostname, @family, @ip, @port = hostname, family, ip, port
@ -283,10 +283,9 @@ module CryptCheck
end
Method.each do |method|
method = method.name
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{method.to_s.downcase}?
@supported_methods.detect { |m| m.name == method }
def #{method.to_sym.downcase}?
@supported_methods.detect { |m| m == method }
end
RUBY_EVAL
end
@ -421,8 +420,7 @@ module CryptCheck
end
def ssl_client(method, ciphers = nil, curves: nil, fallback: false, &block)
method = method.name
ssl_context = ::OpenSSL::SSL::SSLContext.new method
ssl_context = ::OpenSSL::SSL::SSLContext.new method.to_sym
ssl_context.enable_fallback_scsv if fallback
if ciphers

Loading…
Cancel
Save