Configure Webrick to Use Automatically Generated Self-Signed Ssl/Https Certificate

Configure WEBrick to use automatically generated self-signed SSL/HTTPS certificate

Okay, I figured out what was wrong, I should've paid closer attention to the instructions for HTTPS in WEBrick, this is the exact code from the example:

require 'webrick'
require 'webrick/https' # SEE THIS?

cert_name = [
%w[CN localhost],
]

server = WEBrick::HTTPServer.new(:Port => 8000,
:SSLEnable => true,
:SSLCertName => cert_name)

See that line that says require 'webrick/https'? I didn't have that in my original config. I didn't think that I'd need it.

Once I added it, my script started serving over HTTPS, and I could finally connect to https://localhost:4430/robots.txt. <face-palm>

How do I configure WEBrick to use an intermediate certificate with HTTPS?

I managed to find an answer after an extra hour of googling for keywords. Here is the option to define an intermediate certificate:

:SSLExtraChainCert => [
OpenSSL::X509::Certificate.new(
File.open("certificates/intermediate.crt").read)]

Note that the option requires an Array object, allowing to you include multiple certificates if needed.

webrick using ssl whats to do?

Most people solve this by switching from webrick to thin (or even better, unicorn/puma/passenger). I don't think webrick is designed to run in production.

You could also terminate SSL at apache so that webrick only handles http. (Also, assuming Apache is running on the same box, you don't need to bind to 0.0.0.0. Localhost will do, and binding to an external IP sounds like a security vulnerability.)

If you really want to keep webrick and have it handle SSL, you change bin/rails as described in this other answer.

Configuring Webrick in rails 3.0 to serve both http and https (SSL)

I solved the issue by switching Nginx but could not do it using Webrick. I guess Webrick does not support two instances of a server simultaneously and to switch you need to stop the current server and restart the server which has got https:// settings.

rails 3.2.3 doesn't work on https using webrick in ubuntu 12.0.4

The servers which you have used in dev mode doesn't seem to provide an ssl certificate to the client.

For dev purposes you can use "Thin" as it provides a ssl certificate if you start the server with the following command:

"thin start --ssl"
instead of the usual:

"rails s/rails server"



Related Topics



Leave a reply



Submit