Skip to content

Configuring SSL with Let's Encrypt for Martini Server Runtime

Using Let's Encrypt is an excellent way to obtain free 90-day SSL certificates for testing and development purposes for your Martini applications. This guide walks you through the process of generating an SSL certificate using Certbot and configuring it for use with Martini.

Prerequisites

  • Certbot: Make sure you have Certbot installed. You can find installation instructions on the Certbot website.

Generating SSL Certificates

1. Generate a Certificate with Certbot

To generate a certificate, you must verify your domain. One method to do this is by using a manual DNS challenge. For detailed options, refer to the Certbot documentation here.

Run the following command, replacing www.YourDomain.com with your domain:

1
certbot certonly --manual --preferred-challenges dns -d www.YourDomain.com

2. Convert Certificates to PKCS12 Format

After successfully generating the certificate, you need to convert the fullchain.pem and privkey.pem files into PKCS12 format for use in Martini. Use the following command:

1
openssl pkcs12 -export -in /etc/letsencrypt/live/www.YourDomain.com/fullchain.pem -inkey /etc/letsencrypt/live/www.YourDomain.com/privkey.pem -out www.YourDomain.com.p12 -passout pass:your-password

Note: Remember the password you set here, as it will be required later in your Martini configuration.

Martini Configuration

To configure your Martini Runtime to use the newly created SSL certificate, edit the override.properties file located at <martini-home>/conf/override.properties.

Add or update the following properties:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Directory of your keystore certificate
server.tomcat.https.keystoreFile=<keystore-dir>/www.YourDomain.com.p12
# Your keystore certificate password
server.tomcat.https.keystorePass=your-password
# Tomcat HTTP server port
# The default Martini port is 8080. Change it to 80 to redirect browsers to HTTPS.
server.http.port=80
# Tomcat HTTPS server port
# Enable this to use HTTPS with the SSL certificate assigned.
server.https.port=443

3. Start or Restart Martini Runtime

Start the Martini Runtime if it is not already running. If it is running, restart it to apply the changes.

4. Verify SSL Installation

Visit https://www.YourDomain.com in your web browser to verify that your SSL certificate is installed correctly.