How to get a GoDaddy SSL certificate and set it up on Heroku
Friday, April 16th, 2010Update: I was getting warnings on some browsers, and so I updated this post to include the gd_bundle.crt file when generating the .pem, as suggested here.
The first thing to do is go to GoDaddy and purchase a Standard SSL Certificate. This costs $30/year.
Then, starting from your app folder…
mkdir ../ssl-cert cd ../ssl-cert openssl genrsa -des3 -out host.key 2048
Enter a passphrase and remember it, because we’ll have to remove it later. That will generate a key file. Next we need to generate the certificate request:
openssl req -new -key host.key -out host.csr
You’ll have to enter your passphrase here and answer a few questions. Enter something like this:
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:California
Locality Name (eg, city) []:San Diego
Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Company
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:secure.yourapp.com
Email Address []:info@yourapp.comPlease enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
I think it’s important you enter the domain you want to use the certificate on as Your Name. And Heroku’s Hostname Based Custom SSL only works on a subdomain like secure.yourapp.com or www.yourapp.com. If you want to use it on yourapp.com you have to pony up the $100/month for the IP-based solution.
Next, copy the contents of host.csr and paste them into GoDaddy’s form. Instructions to get to the form for requesting a certificate
are here. They will give you a zip file to download. Copy it into your ../ssl-cert folder, and do:
unzip secure.yourapp.com.zip cat secure.yourapp.com.crt gd_bundle.crt host.key > host.pem
Now we have to remove the passphrase:
openssl rsa -in host.pem -out nopassphrase.pem openssl x509 -in host.pem >>nopassphrase.pem openssl rsa -in host.key -out nopassphrase.key
And then activate SSL on heroku:
cd ../yourapp heroku ssl:add ../ssl-cert/nopassphrase.pem ../ssl-cert/nopassphrase.key heroku addons:add custom_domains:basic heroku domains:add secure.yourapp.com heroku addons:add ssl:hostname
That last line will sign you up for a $20/month charge from Heroku. ECommerce ain’t cheap. Finally, you need to go to your DNS provider and create a CNAME pointing secure.yourapp.com at the Amazon EC2 domain that Heroku will have emailed you. It will be something.amazonaws.com.
After all of that, you should be able to go to https://secure.yourapp.com and see the nice little lock in the URL bar, with no scary warnings for your users. In my case, I’m still apparently serving some insecure items on the page (images, maybe?) but that’s a much lesser warning than the “get out of here now!” warning users get when you don’t have a proper certificate set up.