lib/socketry/ssl/server.rb in socketry-0.2.0 vs lib/socketry/ssl/server.rb in socketry-0.3.0
- old
+ new
@@ -10,17 +10,19 @@
# @return [Socketry::SSL::Server]
def initialize(
hostname_or_port,
port = nil,
ssl_socket_class: OpenSSL::SSL::SSLSocket,
+ ssl_context: OpenSSL::SSL::SSLContext.new,
ssl_params: nil,
**args
)
+ raise TypeError, "invalid SSL context (#{ssl_context.class})" unless ssl_context.is_a?(OpenSSL::SSL::SSLContext)
raise TypeError, "expected Hash, got #{ssl_params.class}" if ssl_params && !ssl_params.is_a?(Hash)
@ssl_socket_class = ssl_socket_class
- @ssl_context = OpenSSL::SSL::SSLContext.new
- @ssl_context.set_params(ssl_params) if ssl_params
+ @ssl_context = ssl_context
+ @ssl_context.set_params(ssl_params) if ssl_params && !ssl_params.empty?
@ssl_context.freeze
super(hostname_or_port, port, **args)
end