2

Sinatra アプリケーション、Ubuntu 12

#config.ru
require 'sinatra/base'
require 'openssl'
require 'webrick'
require 'webrick/https'

class App1 < Sinatra::Base
  get '/' do
    'app1'
  end
end

class App2 < Sinatra::Base
  get '/' do
    'app2'
  end
end

app = Rack::Builder.new do 
  map '/app1' do
    run App1
  end
  map '/app2' do
    run App2
  end
end

webrick_options = {
  :Port               => 8443,
  :Logger             => WEBrick::Log::new($stdout, WEBrick::Log::DEBUG),
  :DocumentRoot       => "./public",
  :SSLEnable          => true,
  :SSLCertificate     => OpenSSL::X509::Certificate.new(  File.open("/etc/ssl/certs/ssl-cert-snakeoil.pem").read),
  :SSLPrivateKey      => OpenSSL::PKey::RSA.new(          File.open("/etc/ssl/private/ssl-cert-snakeoil.key").read),
  :SSLCertName        => [ [ "CN",WEBrick::Utils::getservername ] ]
}

Rack::Handler::WEBrick.run app, webrick_options

それから私はそれを実行します

sudo rackup

それは実行され、問題ないようです:

[2012-11-06 16:10:14] INFO  WEBrick 1.3.1
[2012-11-06 16:10:14] INFO  ruby 1.9.3 (2012-04-20) [x86_64-linux]
[2012-11-06 16:10:14] DEBUG TCPServer.new(0.0.0.0, 8443)
[2012-11-06 16:10:14] DEBUG TCPServer.new(::, 8443)
.......

しかし、私が行くとき、私http://localhost:8443/app1は得る

[2012-11-06 17:07:25] ERROR OpenSSL::SSL::SSLError: SSL_accept returned=1 errno=0 state=unknown state: http request
        /usr/lib/ruby/1.9.1/openssl/ssl-internal.rb:164:in `accept'
[2012-11-06 17:07:25] ERROR OpenSSL::SSL::SSLError: SSL_accept returned=1 errno=0 state=unknown state: http request
        /usr/lib/ruby/1.9.1/openssl/ssl-internal.rb:164:in `accept'
[2012-11-06 17:07:25] ERROR OpenSSL::SSL::SSLError: SSL_accept returned=1 errno=0 state=unknown state: http request
        /usr/lib/ruby/1.9.1/openssl/ssl-internal.rb:164:in `accept'

ページ内の「この Web ページは利用できません」というラベル。

私は何を間違っていますか?

4

1 に答える 1