How to use openssl with TCPSocket

Hi,

I have something like this here:

irc = TCPSocket.open(@server_name, @port)

ssl_context = OpenSSL::SSL::SSLContext.new
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
irc = OpenSSL::SSL::SSLSocket.new(irc, ssl_context)
irc.sync = true
irc.connect

Does not work as is though.

Does one of you have a working example of using ruby openssl
and a socket?

I wrote a tiny IRC class, which connects to IRC, then it
allows me to talk there. I would like to add openssl
support, but I can not figure it out.

The above code failed via:

in `connect': SSL_connect returned=1 errno=0 state=unknown state:
unknown protocol (OpenSSL::SSL::SSLError)

And the official documentation to ruby-openssl is just absolutely awful,
in my opinion.

···

--
Posted via http://www.ruby-forum.com/.

Are you connecting on a different port? Otherwise the server doesn't
know you want to use ssl.

If it's a shared port you will need to negotiate that you want to use
SSL before you start it.

···

--
Posted via http://www.ruby-forum.com/.