Upgrading a socket to an SSLSocket

B

Baduk Baduk

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 =)

Thanks
 
R

Roger Pack

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
 
B

Brian Candler

Baduk said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top