Baduk Baduk wrote:
Is it possible to ‘upgrade’ a normal socket to an SSL socket. I would
like to transmit and receive some data in plain text initially, before
performing the SSL handshake and start communicating securely, without
having to close and create a new socket.
Does anyone have an example of this, preferably the more complete the
There’s a complete working example of this in ruby-ldapserver, see
lib/ldap/server/connection.rb. The core is:
def startssl # :yields:
raise LDAP::ResultError::OperationsError if @ssl or
@active_reqs.size > 0
yield if block_given?
@io = OpenSSL::SSL::SSLSocket.new(@io, @opt[:ssl_ctx])
@io.sync_close = true
@ssl = true