Skip to content

Instantly share code, notes, and snippets.

@simonyeldon
Last active September 19, 2019 09:20
Show Gist options
  • Save simonyeldon/698fa22cae9de87fcc0f4a93deafc9d9 to your computer and use it in GitHub Desktop.
Save simonyeldon/698fa22cae9de87fcc0f4a93deafc9d9 to your computer and use it in GitHub Desktop.

Plex Lets Encrypt Automatic Cron

Take a certificate from Lets Encrypt and turn it into a pfx file for Plex to use.

Change the variables CERT_LOCATION and PLEX_LOCATION to the correct paths.

This creates a certificate without a password. If you want to add one, change the cron on line 12, adding your password directly after pass:.

Place this file in the /etc/cron.daily folder to run it each night.

The script assumes that you have the settings for the ssl set up inside plex. If you dont, go to Settings (icon on top right corner) > Server > Network (left navigation column). You may need to show advanced.

  • Custom certificate location: This should be the same as PLEX_LOCATION.
  • Custom certificate encryption key: This should be the same as your password in the script.
  • Custom certificate domain: This should be the same as the domain that Lets Encrypt issue the certificate for.
#!/bin/bash
CERT_LOCATION=/etc/letsencrypt/live/your.plex.domain
PLEX_LOCATION=/var/lib/plexmediaserver/
#OPTIONAL, remove # to run renew beforehand
# certbot renew
openssl pkcs12 -export -out $PLEX_LOCATION/certificate.pfx \
-inkey $CERT_LOCATION/privkey.pem \
-in $CERT_LOCATION/cert.pem \
-certfile $CERT_LOCATION/chain.pem \
-passout pass:
chown plex:plex $PLEX_LOCATION/certificate.pfx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment