对于用于开发的服务器 ssl 证书配置,请将以下代码添加到 script/rails 文件中,
module Rails
class Server < ::Rack::Server
def default_options
super.merge({
:Port => 3445,
:environment => (ENV['RAILS_ENV'] || "development").dup,
:daemonize => false,
:debugger => false,
:pid => File.expand_path("tmp/pids/server.pid"),
:config => File.expand_path("config.ru"),
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLPrivateKey => OpenSSL::PKey::RSA.new(
File.open("/home/mohanraj/myCA/server_key.pem").read),
:SSLCertificate => OpenSSL::X509::Certificate.new(
File.open("/home/mohanraj/myCA/server_crt.pem").read),
:SSLCertName => [["CN", WEBrick::Utils::getservername]]
})
end
end
end
注意:请为 ssl 文件提供正确的路径。
请按照此链接进行重定向http://www.railway.at/2013/02/12/using-ssl-in-your-local-rails-environment/