views:

936

answers:

3

I need to test HTTPS connections to my local Rails script/server instance in development it doesn't seem to be supported and I wasn't able to Google-up any solutions.

Here's what it looks like from the client perspective:

ted@teflon-ted ~/Downloads[master]$ grep tedslaptop /etc/hosts
127.0.0.1   api.tedslaptop.com
ted@teflon-ted ~/Downloads[master]$ /usr/bin/curl https://api.tedslaptop.com:3000/
curl: (35) Unknown SSL protocol error in connection to api.tedslaptop.com:3000 

And here's what I see on the server:

$ script/server 
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails 2.2.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready.  TERM => stop.  USR2 => restart.  INT => stop (no restart).
** Rails signals registered.  HUP => reload (without restart).  It might not work well.
** Mongrel 1.1.5 available at 0.0.0.0:3000
** Use CTRL-C to stop.
Fri Jan 16 13:06:50 -0500 2009: HTTP parse error, malformed request (127.0.0.1): #
Fri Jan 16 13:06:50 -0500 2009: REQUEST DATA: "\200d\001\003\001\000K\000\000\000\020\000\0009\000\0008\000\0005\000\000\026\000\000\023\000\000\n\a\000?\0003\000\0002\000\000/\003\000\200\000\000\005\000\000\004\001\000\200\000\000\025\000\000\022\000\000\t\006\000@\000\000\024\000\000\021\000\000\b\000\000\006\004\000\200\000\000\003\002\000\200xa\377\\?wEM??/\235F\020\232"
---
PARAMS: {}
---
A: 

use apache and mod_rewrite

l_39217_l
+8  A: 

HTTPS is something that is handled outside the Rails framework. Therefore, you cannot test it directly. The functionality that your Rails application provides should be exactly the same on HTTPS as it is on unencrypted HTTP.

script/server uses Mongrel to serve your requests. Mongrel does not support SSL / HTTPS directly.

If you really want to test HTTPS functionality, you have to setup Apache (or another webserver) with SSL/HTTPS support (using mod_ssl), and configure it to run your Rails application (using mod_rails or mod_proxy).

wvanbergen
A: 

Create a self-signed certificate. http://www.flatmtn.com/article/setting-ssl-certificates-apache

Jon