SSL and OpenSSL::SSL::SSLServer accept()

i need to make secure connection between this rubyserver and web-browser

ruby code:

require "openssl"
require 'socket'
port = 443
ctx = OpenSSL::SSL::SSLContext.new()
ctx.ciphers = "ADH"
tcps = TCPServer.new(port)
ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx)
while (session = ssls.accept) # !program interrupts here!
  puts session.gets
  session.puts Time.new
  session.close
end

in browser i enter "127.0.0.1:443" and in console i can watch

bash:

[root@COR rubyserv]# ./rubyserv.rb
/usr/lib/ruby/1.8/openssl/ssl.rb:122:in `accept': http request
(OpenSSL::SSL::SSLError)
from /usr/lib/ruby/1.8/openssl/ssl.rb:122:in `accept'
from ./rubyserv.rb:8

what i do wrong?

···

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

Well though somebody

···

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

Good Evening (or maybe morrning in your neck of the world)

i need to make secure connection between this rubyserver and web-browser

ruby code:
> require "openssl"
> require 'socket'
> port = 443
> ctx = OpenSSL::SSL::SSLContext.new()
> ctx.ciphers = "ADH"
> tcps = TCPServer.new(port)
> ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx)
> while (session = ssls.accept) # !program interrupts here!
> puts session.gets
> session.puts Time.new
> session.close
> end

in browser i enter "127.0.0.1:443" and in console i can watch

First, you are making a http://127.0.0.1:443 call from your browser to an
https server - http != https :slight_smile:

Second, I would strongly suggset you not go down this path - you want to
write your ruby server/app and not an https server. Tools like nginx + thin
+ rack (with your app attaching as a rack middleware) would make so much
more sense in 99% of cases. It might take a small amount of time to write up
the config files for the pieces but they are strong solid workhorses that
you aren't going to readily duplicate.

John

···

On Fri, Sep 25, 2009 at 1:41 PM, born in USSR <psixxx@bk.ru> wrote: