From: Erick Cantwell Date: 2009-03-17T11:54:35+09:00 Subject: Re: SSLServer crashes when non-essl telnet connection is made Michal, You were absolutely correct in that I was getting an SSL exception, but I refused to believe that this should be "normal" behavior. In my opinion an SSLServer in ruby should not crash by default when an unencrypted connection is made. I started digging deeper and I ended up fixing it by modifying the actual openssl/ssl.rb file. Previously the code in the "accept" method looked like this: def accept sock = @svr.accept begin ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx) ssl.sync_close = true ssl.accept if @start_immediately ssl rescue SSLError => ex sock.close raise ex end end I have modified it by adding an extra rescue clause: def accept sock = @svr.accept begin ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx) ssl.sync_close = true begin ssl.accept if @start_immediately rescue SSLError => ex3 ssl.close end ssl rescue SSLError => ex sock.close raise ex end end This still spews an error server side but my server does not crash anymore. I can probably add more code and handle the exception more gracefully, but for now this will do. **This fix does not work for the example code that I posted above so this is not a universal fix. It does fix the issue in my SSLServer that uses Threads, though. Thank you to everyone and their suggestions. -- Posted via http://www.ruby-forum.com/.