I have been working with the SSLServer class in Ruby and have run across
a problem that I cannot get my head around:
My basic server application accepts and handles SSL connections as it
should (or as I think it should), but when I use telnet (non-SSL
encrypted) the server crashes.
I immediately assumed that there was a problem in my code so I began
stripping it down to the bare minimum required. However, when this did
not correct the issue, I ended up with the most basic SSLServer possible
and the symptoms have not gone away.
Current test code(this code is not mine, but was the most basic
SSLServer example that I could find…the result is the same with this
code and my code):
ctx = SSL::SSLContext.new()
ctx.cert = X509::Certificate.new(File.read(’/home/riot82/blah.crt’))
ctx.key = PKey::RSA.new(File.read(’/home/riot82/blah.key’))
svr = TCPServer.new(2007)
serv = SSL::SSLServer.new(svr, ctx)
while soc = serv.accept
This code works like I would expect when testing a connection with:
openssl s_client -connect localhost:2007
However, a simple telnet test:
telnet localhost 2007
Telnet makes the connection, but upon exit the server crashes with the
following error message:
accept': SSL_accept SYSCALL returned=5 errno=0 state=SSLv2/v3 read client hello A (OpenSSL::SSL::SSLError) from /usr/lib/ruby/1.8/openssl/ssl.rb:171:inaccept’
from ./server3.rb:14:in `loop’
I have been able to duplicate this error on both my computer at work
(Ubuntu) and on my workstation at home(Slackware 12.2). Both are
running ruby 1.8.7.
Since I am making the assumption that my code is still the problem (I
have googled around for anybody having this same problem but have been
unable to find anything) if somebody could possibly help point me in the
right direction it would be most appreciated.
*If somebody is aware of a problem in the actual library itself(I looked
at class but was unable to see anything that I would call
“wrong”…maybe an error could be handled more gracefully though?) or if
this was a known issue and has been fixed in 1.9 I would also love to
Thank you again to anybody that can help.