Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you handle SSL in development?

I have an application that uses HTTPS for some of its routes in conjunction with the ssl_requirement plugin. It's deployed and is working fine in production.

The question is how best to handle this in development, because at the moment I'm simply hacking my routes.rb to remove the :requirements key and obviously that's not very convenient or elegant:

map.resource :session, :controller => 'session',
                       :only => [:new, :create, :destroy],
                       :requirements => { :protocol => 'https' }

Ideally I'd like to be able to run the secure parts of my application in development on Mongrel without any changes. How can I achieve this? I'm using Mac OS X.

like image 517
John Topley Avatar asked Jan 22 '10 16:01

John Topley


People also ask

What is SSL in development?

SSL (Secure Sockets Layer) is a layer of security that can be applied to websites on the internet. It is very useful for sites that require visitors to store personal information.

What is SSL handling?

SSL (Secure Sockets Layer) is a standard security protocol for establishing secure connection between the server and the client. Browser and the server use SSL Certificate mechanism to be able to establish a secure connection.

What is SSL and how do you implement it?

SSL stands for Secure Sockets Layer and, in short, it's the standard technology for keeping an internet connection secure and safeguarding any sensitive data that is being sent between two systems, preventing criminals from reading and modifying any information transferred, including potential personal details.


2 Answers

Don't worry about SSL in development

For a development environment, IMO, you don't need to run SSL. It's not worth the time or hassle, especially as more people join the team. With regards to your routes, I would simply keep the protocol as http in the development environment:

protocol = Rails.env.development? ? "http" : "https"

map.resource :session, :controller => 'session',
                       :only => [:new, :create, :destroy],
                       :requirements => { :protocol => protocol }

Now, where you do need to test your SSL integration is on your staging environment -- the place where you deploy to just prior to deploying to production. This is where you want to accurately replicate your production environment. Your development environment does not need to match your production environment in this same way.

like image 130
Ryan McGeary Avatar answered Oct 08 '22 00:10

Ryan McGeary


As your rails apps get more complicated and you want to use advanced features like SSL your best bet is to switch to a development environment which more closely matches your production environment. This will allow you to create your own SSL certs and test in a way which will mirror the way your users will use your application.

I suggest moving to the same webserver as you use in production, which you've mentioned is apache/passenger.

In a related question... how do you manage your test environment with ssl? For this I'm currently hacking up my routes as you're doing. Is there a better way?

like image 24
jonnii Avatar answered Oct 07 '22 23:10

jonnii