SSL Endpoint

Last Updated: 16 April 2015

https ssl

Table of Contents

SSL is a cryptographic protocol that provides end-to-end encryption and integrity for all web requests. Apps that transmit sensitive data should enable SSL to ensure all information is transmitted securely.

To enable SSL on a custom domain, for example,, use the SSL Endpoint add-on.

SSL Endpoint is a paid add-on service. Please keep this in mind when provisioning the service.

SSL Endpoint is only useful for custom domains. All default domains are already SSL-enabled and can be accessed by using https, for example,


Because of the unique nature of SSL validation, provisioning SSL for your application is a multi-step process that involves several third parties. You will need to:

  1. Purchase an SSL certificate from your SSL provider
  2. Provision an SSL endpoint from Heroku
  3. Upload the certificate to Heroku
  4. Update your DNS settings to reference the new SSL endpoint URL

Acquire SSL certificate

Staging, and other non-production, apps can use a free self-signed SSL certificate instead of purchasing one.

Purchasing an SSL certificate varies in cost and process depending on the vendor. DNSimple and ExpeditedSSL offer simple ways to purchase a certificate and are recommended solutions. If you’re able to use one of these providers, see purchasing an SSL cert with DNSimple or the Dev Center article on ExpeditedSSL for instructions.

Otherwise, using other SSL providers will require some or all of the following steps.

Generate private key

Before requesting an SSL cert, you need to generate a private key in your local environment using the openssl tool. If you aren’t able to execute the openssl command from the terminal you may need to install it.

If you have… Install with…
Mac OS X Homebrew: brew install openssl
Windows Windows complete package .exe installer
Ubuntu Linux apt-get install openssl

Use openssl to generate a new private key.

When prompted, enter an easy password value as it will only be used when generating the CSR and not by your app at runtime.

$ openssl genrsa -des3 -out server.pass.key 2048
Enter pass phrase for server.pass.key:
Verifying - Enter pass phrase for server.pass.key:

The private key needs to be stripped of its password so it can be loaded without manually entering the password.

$ openssl rsa -in server.pass.key -out server.key

You now have a server.key private key file in your current working directory.

Generate CSR

A CSR is a certificate signing request and is also required when purchasing an SSL cert. Using the private key from the previous step, generate the CSR. This will require you to enter identifying information about your organization and domain.

Though most fields are self-explanatory, pay close attention to the following:

Field Description
Country Name The two letter code, in ISO 3166-1 format, of the country in which your organization is based.
Common Name This is the fully qualified domain name that you wish to secure.
  • For a single subdomain:
  • For all subdomains, specify the wildcard URL: *
  • For the root domain:

The Common Name field must match the secure domain. You cannot purchase a certificate for the root domain, (for example,, and expect to secure The inverse is also true. Additionally, SSL Endpoint only supports one certificate per app. Please keep this in mind for multi-domain applications and specify a Common Domain that matches all required domains.

Generate the CSR:

$ openssl req -nodes -new -key server.key -out server.csr
Country Name (2 letter code) [AU]:US
Common Name (eg, YOUR name) []

The result of this operation will be a server.csr file in your local directory (alongside the server.key private key file from the previous step).

Submit CSR to SSL provider

Next, begin the process of creating a new SSL certificate with your chosen certificate provider. This will vary depending on your provider, but at some point you will need to upload the CSR generated in the previous step.

You may also be asked for what web server to create the certificate. If so, select Nginx as the web server for use on Heroku. If Nginx is not an option, Apache 2.x will also suffice.

If you’re given an option of what certificate format to use, such as PKCS or X.509, choose X.509.

If you want to secure more than one subdomain you will need to purchase a wildcard certificate from your provider. While these certificates are typically more expensive, they allow you to serve requests for all subdomains of * over SSL.

On completion of the SSL certificate purchase process you should have several files including:

  • The SSL certificate for the domain specified in your CSR, downloaded from your certificate provider. This file will have either a .pem or .crt extension.
  • The private key you generated in the first step, server.key.

Provision the add-on

Once you have the SSL certificate file and private key you are ready to configure SSL Endpoint for your app. First, provision an endpoint.

$ heroku addons:add ssl:endpoint
Adding ssl:endpoint on example... done, v1 ($20/mo)

Next add your certificate, any intermediate certificates, and private key to the endpoint with the certs:add command.

Heroku automatically strips out unnecessary parts of the certificate chain as part of the certs:add command. In some scenarios, this may not be desired.

$ heroku certs:add server.crt server.key
Adding SSL Endpoint to example... done
example now served by
Certificate details:
Expires At: 2012-10-31 21:53:18 GMT
Issuer: C=US; ST=CA; L=SF; O=Heroku;
Starts At: 2011-11-01 21:53:18 GMT

The endpoint URL assigned to your app will be listed in the output, in this example. Visiting this URL will result in a “no such app” message – this is expected. Read further for proper verification steps.

Apps located in a non-default region, for example, Europe, will not have a distinct SSL endpoint URL. Instead, the endpoint URL will just be your app’s herokuapp domain, for example, The output of the certs:add command will accurately reflect this.

Endpoint details

You can verify the details of the SSL endpoint configuration with heroku certs.

$ heroku certs
Endpoint                    Common Name         Expires                    Trusted
------------------------    ----------------    -----------------------    -------    2012-10-31 21:53:18 GMT    False

To get the detailed information about a certificate, use certs:info.

$ heroku certs:info
Fetching SSL Endpoint info for example... done
Certificate details:
Expires At: 2012-10-31 21:53:18 GMT
Issuer: C=US; ST=CA; L=SF; O=Heroku;
Starts At: 2011-11-01 21:53:18 GMT
Subject: C=US; ST=CA; L=SF; O=Heroku;

In very rare circumstances, it can take an SSL endpoint an extended period (30 minutes to 2 hours) before it’s provisioned. If you are unable to hit the endpoint URL, please wait that amount of time before proceeding.

If you have a endpoint URL, visit it via https, for example, This should throw a cert error saying that the certificate at doesn’t match This means that you are serving up the certificate that you’d expect to serve (just not for the requested domain).

DNS and domain configuration

Once the SSL endpoint is provisioned and your certificate is confirmed, you must route requests for your secure domain through the endpoint URL. Unless you’ve already done so, add the domain specified when generating the CSR to your app with:

$ heroku domains:add
Added to example... done

Assuming proper custom domain DNS configuration already, apps located in a non-default region, for example, Europe, will not have to make any additional DNS modifications. Such apps can skip the remainder of this DNS section.


If you’re securing a subdomain, for example,, modify your DNS settings and create a CNAME record to the endpoint or modify the CNAME target if you already have a CNAME record.

Record Name Target

If you’re using a wildcard certificate your DNS setup will look similar.

Record Name Target

Root domain

If you’re securing a root domain, for example,, you must be using a DNS provider that provides CNAME-like functionality at the zone apex.

Modify your DNS settings and create an ALIAS or ANAME record to the endpoint.

Record Name Target
ALIAS or ANAME <empty> or @

Testing SSL

Use a command line utility like curl to test that everything is configured correctly for your secure domain.

The -k option tells curl to ignore untrusted certificates.

$ curl -kvI
* About to connect() to port 443 (#0)
*   Trying connected
* Connected to ( port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using AES256-SHA
* Server certificate:
*    subject: C=US; ST=CA; L=SF; O=SFDC; OU=Heroku;
*    start date: 2011-11-01 17:18:11 GMT
*    expire date: 2012-10-31 17:18:11 GMT
*    common name: (matched)
*    issuer: C=US; ST=CA; L=SF; O=SFDC; OU=Heroku;
*    SSL certificate verify ok.
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3
> Host:
> Accept: */*

Pay attention to the output. It should print SSL certificate verify ok. If it prints something like common name: (does not match '') then something is not configured correctly.

Update certificate

Heroku automatically strips out unnecessary parts of the certificate chain as part of the certs:update command. In some scenarios, this may not be desired. To avoid this automatic manipulation of the chain, include the --bypass flag.

You can update a certificate using the certs:update command with the new certificate and existing private key:

$ heroku certs:update server.crt server.key
Updating SSL Endpoint endpoint for example... done


If, for some reason, the new certificate is not working properly and traffic to your app is being disrupted, you can roll back to the previous certificate:

$ heroku certs:rollback
Rolling back SSL Endpoint endpoint on example... done

If there is no previous certificate, this command will fail.

Heroku will clean up and remove non-active expired certificates after a month. Attempting to roll back to an expired certificate will not work.

Remove certificate

You can remove a certificate using the certs:remove command:

$ heroku certs:remove
Removing SSL Endpoint endpoint on example... done

Removing a certificate does not stop billing. To stop billing, you must remove the SSL endpoint add-on. Remove the add-on with heroku addons:remove ssl:endpoint.

If you try to remove the SSL endpoint add-on before the certificate is removed, you will receive an error.

Client IP address

When an end-client (often the browser) initiates an SSL request, the request must be decrypted before being sent to your app. This extra SSL termination step obfuscates the originating IP address of the request. As a workaround, the IP address of the external client is added to the X-Forwarded-For HTTP request header.


SSL Endpoint infrastructure is elastic and scales automatically based on historical traffic levels. However, if you plan to switch a lot of traffic to a newly created SSL endpoint or if you expect large spikes, contact Heroku support so we can help with preemptive scaling.

An initial request rate of greater than 150 requests/sec or a doubling of the existing requests/second within a 5 minute period are the thresholds at which you should consider contacting support to pre-warm your endpoint. Please give us at least 2 business days advanced notice for these types of requests.


Untrusted certificate

In some cases, when running heroku certs it may list your certificate as untrusted.

$ heroku certs
Endpoint                    Common Name         Expires                    Trusted
------------------------    ----------------    -----------------------    -------    2012-10-31 21:53:18 GMT    False

If this occurs it may be because it is not trusted by Mozilla’s list of root CA’s. If this is the case your certificate should work as you expect for many browsers.

If you have uploaded a certificate that was signed by a root authority but you get the message that it is not trusted, then something is wrong with the certificate. For example, it may be missing intermediary certificates. If so, download the intermediary certificates from your SSL provider and re-run the certs:add command.

Internal server error

If you get an Internal server error when adding your certificate, it may be that you have an outdated version of the Heroku Toolbelt.

$ heroku certs:add server.crt server.key
Adding SSL endpoint to example... failed
! Internal server error.
! Run 'heroku status' to check for known platform issues.

Verify your toolbelt installation and update it to the latest version with heroku update.

SSL file types

Many different file types are produced and consumed when creating an SSL certificate.

  • A .csr file is a certificate signing request, which initiates your certificate request with a certificate provider and contains administrative information about your organization.
  • A .key file is the private key used for your site’s SSL-enabled requests.
  • .pem and .crt extensions are often used interchangeably and are both base64 ASCII encoded files. The technical difference is that .pem files contain both the certificate and key whereas a .crt file only contains the certificate. In reality this distinction is often ignored.