How to use openssl with TCPSocket


I have something like this here:

irc =, @port)

ssl_context =
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
irc =, ssl_context)
irc.sync = true

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.

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.