class IO::Endpoint::SSLEndpoint
def address
def address @endpoint.address end
def bind
-
(Socket)- the connected socket
Other tags:
- Yield: - the socket which is being connected
def bind if block_given? @endpoint.bind do |server| yield ::OpenSSL::SSL::SSLServer.new(server, context) end else @endpoint.bind.map do |server| ::OpenSSL::SSL::SSLServer.new(server, context) end end end
def build_context(context = ::OpenSSL::SSL::SSLContext.new)
def build_context(context = ::OpenSSL::SSL::SSLContext.new) if params = self.params context.set_params(params) end # context.setup # context.freeze return context end
def connect(&block)
-
(Socket)- the connected socket
Other tags:
- Yield: - the socket which is being connected
def connect(&block) socket = ::OpenSSL::SSL::SSLSocket.new(@endpoint.connect, context) if hostname = self.hostname socket.hostname = hostname end begin socket.connect rescue socket.close raise end return socket unless block_given? begin yield socket ensure socket.close end end
def context
def context @context ||= build_context end
def each
def each return to_enum unless block_given? @endpoint.each do |endpoint| yield self.class.new(endpoint, **@options) end end
def hostname
def hostname @options[:hostname] || @endpoint.hostname end
def initialize(endpoint, **options)
def initialize(endpoint, **options) super(**options) @endpoint = endpoint if ssl_context = options[:ssl_context] @context = build_context(ssl_context) else @context = nil end end
def params
def params @options[:ssl_params] end
def to_s
def to_s "\#<#{self.class} #{@endpoint}>" end