Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 2.00 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How do I configure WEBrick to use an intermediate certificate with HTTPS?
  2. {
  3.     :Port => 3000,
  4.     :environment => (ENV['RAILS_ENV'] || "development").dup,
  5.     :daemonize => false,
  6.     :debugger => false,
  7.     :pid => File.expand_path("tmp/pids/server.pid"),
  8.     :config => File.expand_path("config.ru"),
  9.     :SSLEnable => true,
  10.     :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
  11.     :SSLPrivateKey => OpenSSL::PKey::RSA.new(
  12.         File.open("certificates/https/key.pem").read),
  13.     :SSLCertificate => OpenSSL::X509::Certificate.new(
  14.         File.open("certificates/https/cert.pem").read),
  15.     :SSLCertName => [["CN", WEBrick::Utils::getservername]]
  16. }
  17.        
  18. :SSLExtraChainCert => [OpenSSL::X509::Certificate.new(
  19.       File.open("certificates/intermediate.crt").read)]
  20.        
  21. #!/usr/bin/env ruby
  22. # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
  23. require 'rubygems' # if ruby 1.8.7
  24. require 'rails/commands/server'
  25. require 'rack'
  26. require 'webrick'
  27. require 'webrick/https'
  28.  
  29. module Rails
  30.     class Server < ::Rack::Server
  31.         def default_options
  32.             super.merge({
  33.                 :Port => 3000,
  34.                 :environment => (ENV['RAILS_ENV'] || "development").dup,
  35.                 :daemonize => false,
  36.                 :debugger => false,
  37.                 :pid => File.expand_path("tmp/pids/server.pid"),
  38.                 :config => File.expand_path("config.ru"),
  39.                 :SSLEnable => true,
  40.                 :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
  41.                 :SSLPrivateKey => OpenSSL::PKey::RSA.new(
  42.                        File.open("/key/vhost1.key").read),
  43.                 :SSLCertificate => OpenSSL::X509::Certificate.new(
  44.                        File.open("/crt/vhost1.crt").read),
  45.                 :SSLCertName => [["CN", WEBrick::Utils::getservername]],
  46.             })
  47.         end
  48.     end
  49. end
  50.  
  51. APP_PATH = File.expand_path('../../config/application',  __FILE__)
  52. require File.expand_path('../../config/boot',  __FILE__)
  53. require 'rails/commands'