Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to setup free SSL for OpenHAB via LetsEncrypt
#!/bin/bash
##############################################################################
#
# Filename:openhab_letsencrypt.sh
# Description: Script to setup free SSL via LetsEncrypt
# Source: https://github.com/hyper3xpl0iter/helper_scripts.git
# Gist: https://gist.github.com/c6472a6d574909e83c4d92c1d0aad4cc.git
# Author: Andre Mattie
# Email: devel@th3c1inic.org
# GPG: B9C0 3976 3CB4 794E D66C 8F75 8AA0 8470 3533 2EDD
# Date: 07/30/2016
#
##############################################################################
DOMAIN=<OPENHAB.DOMAIN.COM>
PASSWORD=<YOUR_PASSWORD>
cd /opt/letsencrypt
service openhab stop
./letsencrypt-auto certonly --renew-by-default --standalone-supported-challenges tls-sni-01 -d ${DOMAIN}
openssl pkcs12 -export -password pass:${PASSWORD} -inkey /etc/letsencrypt/live/${DOMAIN}/privkey.pem -in /etc/letsencrypt/live/${DOMAIN}/fullchain.pem -out /tmp/cert.p12
keytool -importkeystore -srckeystore /tmp/cert.p12 -srcstoretype PKCS12 -destkeystore /tmp/keystore.jks -srcstorepass ${PASSWORD} -deststorepass ${PASSWORD} -noprompt
rm /tmp/cert.p12
mv /tmp/keystore.jks /usr/share/openhab/etc/keystore
service openhab start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment