Skip to content

SSL Certificate (HTTPS) Set Up

Aurora Lahtela edited this page Nov 19, 2023 · 77 revisions

Plan Header

Login / HTTPS Set-Up

This tutorial attempts to guide you through setting up HTTPS on Plan.

Benefits:

  • User login is enabled & data is encrypted during transmit
  • Plugin Version history data becomes visible

These icons are used to aid during installation

💭 Question about possible issues (Someone has had these before)
📢 Important note about the settings being changed
🚧 Additional steps for some users
💡 Extra stuff

Alternatives:

  • If you're using a reverse-proxy with https, you can set up Proxy-settings to transmit in http internally.
  • If you're not able to obtain a certificate, you can use self-signed certificate (Will show a warning when the page is opened)
  • If you can't set up https in any way but still want to secure your website, you can use the built in IP whitelist

✔️ Requirements

  • A domain you can control (eg example.com).
  • Plan installed on a server

🚩 Installation Goals

Here are the goals the tutorial aims to guide you through.
At the end of this tutorial you will have

  • .. obtained a free certificate from Let's Encrypt
    • .. done a HTTP or DNS challenge to prove ownership of domain (Let's Encrypt guides through this.)
  • .. (or obtained a certificate from elsewhere)
  • .. turned the certificate files into a PKCS12 file .p12
    • .. installed OpenSSL
  • .. Secured Plan with HTTPS & Login

After installation it is also possible to

  • .. register users for Plan

Step 1-3: Obtain Free Certificate from Let's Encrypt

Let's Encrypt is a free certificate authority that allows you to get a certificate for you domain easily.

You will be able to obtain .pem certificate files from them using Certbot.

Please have a read through: https://letsencrypt.org/getting-started/

If you have terminal access on your server

📢 Important

Please read through the 5 steps below before continuing.

  1. Open Certbot tutorial
  2. Select 'None of the Above' and Operating System of your server (or OS of your PC if your server has no terminal access). example
  3. Scroll down to 'default' / 'wildcard *' and select one. Wildcard cert is for all subdomains eg. *.domain.com.
  4. Follow the steps in the Certbot tutorial until the step "Install your certificate" and continue this tutorial.
  5. After completing this tutorial, go back to finish rest of the steps in Certbot tutorial.

If you don't have terminal access

Do the same steps as above, but instead of doing them on your server, do them on your computer.

💭 I can't open a port on my router for certbot

Consider an alternative certificate provider or use a self-signed certificate.

Step 4: Creating PKCS12 from Certificate files

🚧 Windows users:

See the Windows version of step 4

You will need to have OpenSSL installed.

  • Most linux distros ship with openssl installed.

From .pem into PKCS12 format (.p12):

  1. Create the .p12 file first
> touch /etc/letsencrypt/live/<domain>/pkcs.p12 

🚧 FTP Client users:
Creating a new file on a FTP client may create a new text file, which will cause the pkcs12 command to fail!

  1. Next, install the cert into the empty file
> openssl pkcs12 -export \
-in /etc/letsencrypt/live/<domain>/fullchain.pem \
-inkey /etc/letsencrypt/live/<domain>/privkey.pem \
-out /etc/letsencrypt/live/<domain>/pkcs.p12 \
-name <alias> \
-passout pass:<password> \
-passin pass:<password>
Example use (click to expand)
openssl pkcs12 -export \
-in /etc/letsencrypt/live/plan.myawesomedomain.com/fullchain.pem \
-inkey /etc/letsencrypt/live/plan.myawesomedomain.com/privkey.pem \
-out /etc/letsencrypt/live/plan.myawesomedomain.com/pkcs.p12 \
-name beans \
-passout pass:MySuperAwesomePassword98437987439 \
-passin pass:MySuperAwesomePassword98437987439
  • Set both passwords to be the same in the config
  • alias: A single word with only lowercase letters. It is required by java so that it can get the correct certificate from the file.
  • If the command fails put it all in one line and remove the \ characters

📢 Important

Write the values you used in the command for settings later.

💭 The command doesn't say anything!

Try writing the command by hand without the \ characters to avoid any funky business with copy-paste

💡 Tip

You might want to write a bash-script to automate pkcs12 creation process in the future in case the certificate expires.

From .crt and .key into PKCS12 format (.p12) (Alternative)

Click to open
> openssl pkcs12 -export \
-in my.crt \
-inkey my.key \
-name <alias> \
-out pkcs.p12
  • The command will ask for store_pass.
  • When entering config settings to Plan leave Key_pass as empty ""

Step 4.1: Set Plan Configuration Settings:

  • Place the .p12 file in the /plugins/Plan/ folder or specify the full path to the file.
Config.Setting Description
SSL_certificate.KeyStore_path Filename in /plugins/Plan/ folder or the absolute path to the file if the certificate is placed elsewhere.
SSL_certificate.Key_pass The password of the certificate (-passin parameter)
SSL_certificate.Store_pass The password of the keystore (-passout parameter)
SSL_certificate.Alias The alias of the keystore (-name parameter)

💭 The page doesn't work after I set the settings!

Make sure that you have https:// in front of the address

💭 I got 'keystore password was incorrect' error after I set Plan settings

Try the command in previous step without -passout and -passin parameters and enter the passwords manually.

Step 5: Finish Certbot tutorial

What next?

Registering users after HTTPS is enabled

To access the web page after enabling HTTPS, you need a Web user.

Web users are registered via the Register page (You can find a link from login page or via /plan register-command)

Before the user registration is complete a command needs to be run to link the user to a player or to the console.

See Web permissions how to set up web permissions for web groups.

Old info for old versions

This mini-section is for version 5.5 or older.

What pages a user can access depends on the permission level of the user. Here is how the level is determined and what they can access:

Level Can access Permission
0 Every page plan.server
1 /players, /query and /player/name pages plan.player.other
2 /player/<linked user> page plan.player.self
100 nothing If player has none of the permissions they are given this level

There is also a legacy way to register users via /plan register <password> <user> <permission level> that requires plan.register.other permission to use

Alternatives

If behind a Proxy

If you are running Plan behind a proxy like Nginx or Apache, and would like to use their HTTPS instead, you can!

  • You need to set SSL_Certificate.KeyStore_path to proxy in Plan config and Plan will run HTTP, but serve all links and requests like it would be running HTTPS. Make sure that your proxy config uses http:// in the proxy pass address.
  • You also need to set Webserver.Alternative_IP settings to point to your proxy address (eg analytics.domain.com)

Example:

Webserver:
    Alternative_IP: true
        Address: analytics.domain.com # The address that your reverse-proxy has
    Security:
        SSL_certificate:
            KeyStore_path: proxy

Using a self-signed certificate

You can generate and use a self-signed certificate with OpenSSL like this:

openssl req -x509 -sha256 -nodes -days 3650 -newkey rsa:4096 -keyout mykey.key -out mypem.pem
openssl pkcs12 -export -out myp12.p12 -inkey mykey.key -in mypem.pem -name {alias}

Set the settings in the Plan config to match.

If you’re unable to obtain a certificate

If you do not have a domain for certificate registration, or can not create a self signed one, Plan.jar contains a self signed RSA 2048 certificate that can be used. Note that the cert inside the jar has expired so it might not work with some browsers

Open Plan.jar in any archive manager (Like 7zip) and drop the PlanCert.jks file in the /plugins/Plan/ folder. Set the config settings as follows so that the Certificate works.

Config.Setting Value
SSL_certificate.KeyStore_path PlanCert.jks
SSL_certificate.Key_pass MnD3bU5HpmPXag0e
SSL_certificate.Store_pass wDwwf663NLTm73gL
SSL_certificate.Alias DefaultPlanCert
        SSL_certificate:
            KeyStore_path: PlanCert.jks
            Key_pass: MnD3bU5HpmPXag0e
            Store_pass: wDwwf663NLTm73gL
            Alias: DefaultPlanCert

Self signed certificates cause browsers to display security warning:
Certificate Warning

You can ignore this warning. “Dangers” of self signed certificates, Article
The warning can be ignored by clicking "Advanced" -> "Continue anyway"


Step 4 for windows users

You will need to have OpenSSL installed.

From .pem into PKCS12 format (.p12):

  1. Create the .p12 file first
> fsutil file createnew C:\Certbot\live\<domain>\pkcs.p12 0

If you're using windows change all /etc/letsencrypt/live/<domain>/ to C:\Certbot\live\<domain>\ in the commands on this page

🚧 FTP Client users:
Creating a new file on a FTP client may create a new text file, which will cause the pkcs12 command to fail!

  1. Next, install the cert into the empty file
openssl pkcs12 -export -in C:\Certbot\live\<domain>\fullchain.pem -inkey C:\Certbot\live\<domain>\privkey.pem -out C:\Certbot\live\<domain>\pkcs.p12 -name <alias> -passout pass:<your_pass> -passin pass:<your_pass>
  • alias is required by java so that it can get the correct certificate. A single word with only lowercase letters is recommended.

📢 Important

Write the values you used in the command for settings later.

💡 Tip

You might want to write a batch-script to automate pkcs12 creation process in the future in case the certificate expires.

Continue from step 4.1

Clone this wiki locally