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
better =)
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.
I think you can do it with eventmachine, since you call start_tls
whenever you want. not sure about normal sockets, maybe there’s a
constructor to SSLSocket that takes a descriptor so you can pass
descriptors about?
-rp
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
better =)
There’s a complete working example of this in ruby-ldapserver, see
lib/ldap/server/connection.rb. The core is:
def startssl # :yields:
@mutex.synchronize do
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 @io.accept @ssl = true
end
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.